Jump to content

ARB

Members
  • Posts

    5
  • Joined

  • Last visited

ARB's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Hi Guys Many thanks for all you help. I have found the problem, and it was in my code. I was not adding the full path and the filename in the file open statement. The other thing that was causing consfusion was that I was getting firewall issues while ftp'ing the files to my PC I think it thought that it was getting a denial of service attack. This resulted in a quantity of files ending up in the script directory, many with zero bytes thus the script was stalling with the file open error. Anyway, thanks again for all your comments. Regards Alan
  2. Hi Guys Many thanks for your comments, here are my replies to the points raised. I have written many interface programs over the last 4 years using AutoIT and this is the first time that I have encountered a problem I could not resolve. It is also the first time that I have attempted to process a large number of files at once. I have written a version using _FileListToArray() but I had the same problem. The data files are imported to my local drive via ftp. I am an admin, therfore have full control of all data. The confussion over the file entry failure was in my haste to post I just copied the last entries. Extract of the Console output: #1566 $os = 28-01-2011,1544,42006696,0500,EX3_SCHSTS_001727449.xml Fileo Handle = 2 processing file EX3_SCHSTS_001727450.xml #1567 $os = 28-01-2011,1544,42006700,0500,EX3_SCHSTS_001727450.xml Fileo Handle = 2 processing file EX3_SCHSTS_001727451.xml #1568 $os = 0,0,,0,EX3_SCHSTS_001727451.xml Below are the files prior to and the point of failure. Prior File content: <?xml version="1.0" encoding="utf-8" ?> - <rmc> <date>28-01-2011</date> <time>1544</time> <summit_co>01</summit_co> <summit_module>jtent</summit_module> <mode>A</mode> - <ticket> <field id="ticket_no">42006714</field> - <field type="mtext" id="jtca_notes"> <text /> </field> - <field id="status"> <value>0500</value> </field> </ticket> </rmc> Error File content: <?xml version="1.0" encoding="utf-8" ?> - <rmc> <date>28-01-2011</date> <time>1544</time> <summit_co>01</summit_co> <summit_module>jtent</summit_module> <mode>A</mode> - <ticket> <field id="ticket_no">42006723</field> - <field type="mtext" id="jtca_notes"> <text /> </field> - <field id="status"> <value>0500</value> </field> </ticket> </rmc> Maybe the fileopen error is a symptom if my previous calls to extract the values or the tags from the xml. here is the function, it may help ;********************************************************************************************* ;$s = String ;$t = Tag ; returns array of values between start and end tags ;********************************************************************************************* Func _XMLData($s,$t) dim $a[1] $nOffset = 1 While 1 $array = StringRegExp($s, '<(?i)' & $t & '>(.*?)</(?i)' & $t & '>', 1, $nOffset) If @error = 0 Then $nOffset = @extended Else ExitLoop EndIf _ArrayAdd($a,$array[0]) return($array[0]) WEnd _ArrayDelete($a,0) ;_ArrayDisplay($a) EndFunc Cheers AlanB
  3. Hi Here is a console extract showing file handle up to the point of failure. Cheers AlanB processing file EX3_SCHSTS_001732538.xml 2166os = 0,0,,0,EX3_SCHSTS_001732538.xml Fileo Handle = 2 processing file EX3_SCHSTS_001732540.xml 2167os = 0,0,,0,EX3_SCHSTS_001732540.xml Fileo Handle = 2 processing file EX3_SCHSTS_001732542.xml 2168os = 0,0,,0,EX3_SCHSTS_001732542.xml Fileo Handle = 2 processing file EX3_SCHSTS_001732544.xml 2169os = 0,0,,0,EX3_SCHSTS_001732544.xml Fileo Handle = 2 processing file EX3_SCHSTS_001732546.xml 2170os = 0,0,,0,EX3_SCHSTS_001732546.xml Fileo Handle = -1
  4. Hi MVP Thanks for your comments here is a code extract. The functions have not been included, _write is just a consolewrite with linefeed, _xmldata() just returns the value for a tag. Cheers AlanB *** Code *** $fld = StringSplit('date,time,ticket,value',",") $filename = "EX3_SCHSTS*.xml" $FileList =_FileListToArray($ftpinlcd , $filename) _write("Filelist = " & $filelist[0]) ;#cs $search = FileFindFirstFile($ftpinlcd & "*.xml") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $cnt = 1 While 1 $xml = "" $os = "" $fileo = "" $file = FileFindNextFile($search) If @error Then ExitLoop $fileo = FileOpen($file, 0) ; Check if file opened for reading OK If $fileo = -1 Then MsgBox(0, "Error", "Unable to open file." & @lf & $file) Exit EndIf _write("processing file " & $file) ; Read in 1 character at a time until the EOF is reached $xml = FileRead($fileo) ;_write("Xml value " & $xml) for $i = 1 to $fld[0] $r = _XMLData($xml,$fld[$i]) if $i = 3 Then $p = StringInStr($r,">") ;_write($p) $s = StringMid($r,$p + 1) ;_write($s) $p = StringInStr($s,"<") ;_write($p) $s = StringLeft($s,$p - 1) ;_write("ticket[" & $fld[$i] & "] = " & $s) $os &= $s & "," Else $os &= $r & "," EndIf Next $os &= $file _write($cnt & "os = " & $os) ;_fillline($os) FileClose($fileo) $cnt += 1 WEnd FileClose($search) Exit
  5. Hopefuly this is the correct place to post this question. I am attempting to loop through a directory opening each file (xml) reading the second line, reformat the content into SQLlite table, closing the file and going back aroud the loop. There could be 30000+ files in the directory. The problem the file fails to open at file 1568. There are several thousand mor to process. Is this bug or limitaion of the fileopen keyword? AlanB
×
×
  • Create New...