Jump to content

tomc

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by tomc

  1. Hi I have a lot of .txt files which contain student's results. Lines 2 & 3 are their name and birth. I'd like to move these .txt to new folders respect to the class number. class number, name, and birth are in a sql table. I tried to use the MySQL UDF an did: #include "FileListToArrayEx.au3" #include "array.au3" #include "mysql.au3" While 1 $results = _FileListToArrayEx(@ScriptDir,'*.txt',1,'',True) If NOT @error Then For $i = 1 to $results[0] $sql = _MySQLConnect("root","xxxxxxxxxx","tbds","localhost") $f = FileOpen( $results[$i], 0 ) $name_f = FileReadLine( $f , 2 ) $birth_f = FileReadLine( $f , 3 ) $classnumb = _Query($sql,"SELECT classnumb FROM students WHERE name = " & $name_f & " AND birth = " & $birth_f ) FileClose($f) _MySQLEnd($sql) FileMove(@ScriptDir & "\" & $results[$i], "C:\" & $classnumb, 8) Next EndIf WEnd this returns no error but does nothing.... Could you tell what I'm doing wrong? Thanks!
  2. Hi all ! I need something to read student's name and birth date in their "results .txt", then fetch their new classroom from a database an finally move their results .txt in the classroom's folder. Maybe a little complicated for one of my first script ... here is what I have actually: #include "FileListToArrayEx.au3" #include "array.au3" #include "mysql.au3" While 1 $results = _FileListToArrayEx(@ScriptDir,'*.txt',1,'',True) If NOT @error Then For $i = 1 to $results[0] $sql = _MySQLConnect("root","","tbds","localhost") $f = FileOpen( $results[$i], 0 ) $nom_f = FileReadLine( $f , 2 ) $naiss_f = FileReadLine( $f , 3 ) ;MsgBox(0,"",$nom_f & $naiss_f) $division = _Query($sql,"SELECT division FROM eleves WHERE nom = " & $nom_f & " AND naiss = " & $naiss_f ) FileClose($f) _MySQLEnd($sql) FileMove(@ScriptDir & "\" & $results[$i], "C:\" & $division, 8) Next EndIf WEnd all results .txt are in the script dir and look like: the csv I made the tbds DB table from: no error message but the script doesn' work... what am I doing wrong?? Thanks!
×
×
  • Create New...