eyegeegeewhy Posted December 5, 2007 Share Posted December 5, 2007 Right I have a text file that looks a bit like this (but much longer and there is more data in it i dont want) [24_125DPI_xml 224_150DPI_pdf 224_150DPI_xml 471Y07N_0001.pdf 471Y07N_bm.xml 471Y07N_bm_config.xml 471Y07N_classified_0019.pdf 471Y07N_classified_0019.xml 471Y07N_classified_0020.pdf 471Y07N_classified_0020.xml 471Y07N_classified_0021.pdf 471Y07N_classified_0021.xml 471Y07N_classified_0022.pdf 471Y07N_classified_0022.xml 471Y07N_classified_0023.pdf 471Y07N_classified_0023.xml 471Y07N_classified_0024.pdf 471Y07N_classified_0024.xml 471Y07N_classified_0025.pdf 471Y07N_classified_0025.xml I am trying to create two text files one with a list of the xml and one with a list of the pdf's. so far the functions look a bit like this $clean_pdf_filelist=FileOpen("C:\Emonitor\clean_file_list_pdf.txt",2) $clean_xml_filelist=FileOpen("C:\Emonitor\clean_file_list_xml.txt",2) Func SORT_DATA() $file_list = FileOpen("C:\Emonitor\ftp_ls.txt",0) While 1 $line = FileReadLine($file_list) call ("FILTER_RESULTS",$line) Wend FileClose($file_list) EndFunc Func FILTER_RESULTS($line) If StringMid($line,9,10) ="classified" then if StringRight($line,3) ="pdf" then FileWrite($clean_pdf_filelist,$line & @CRLF) if StringRight($line,3) ="xml" then FileWrite($clean_xml_filelist,$line & @CRLF) EndIf EndFunc Func CLOSE_OPEN_FILES() FileClose($clean_pdf_filelist) FileClose($clean_xml_filelist) EndFunc Now it all looks like it is working untill it has wrote about a thousand lines (28kilobytes) to each file then my CPU usage rockets and it takes about 1 minute to write the last 125 lines. Im guessing this something to do with how i open and close the files im writing but i cant figure out how to do it better. If some one has an idea on how to do this process in the quickest way that would be really helpful. Cheers Jord Link to comment Share on other sites More sharing options...
DW1 Posted December 5, 2007 Share Posted December 5, 2007 I only see three functions and two file opens... where is the rest of the code to troubleshoot? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
eyegeegeewhy Posted December 5, 2007 Author Share Posted December 5, 2007 I only see three functions and two file opens... where is the rest of the code to troubleshoot? There is only a bit that gets the ls_text file from an ftp server and thats it. I think if you add SORT_DATA() CLOSE_OPEN_FILES() To the very beginning and it can find its files it should run. The text file is just like the sample bit i posted just lots of it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 5, 2007 Share Posted December 5, 2007 Right I have a text file that looks a bit like this (but much longer and there is more data in it i dont want) I am trying to create two text files one with a list of the xml and one with a list of the pdf's. so far the functions look a bit like this Now it all looks like it is working untill it has wrote about a thousand lines (28kilobytes) to each file then my CPU usage rockets and it takes about 1 minute to write the last 125 lines. Im guessing this something to do with how i open and close the files im writing but i cant figure out how to do it better. If some one has an idea on how to do this process in the quickest way that would be really helpful. Cheers Jord You are making it too hard: #include <file.au3> Global $clean_pdf_filelist = FileOpen("C:\Emonitor\clean_file_list_pdf.txt", 2) Global $clean_xml_filelist = FileOpen("C:\Emonitor\clean_file_list_xml.txt", 2) Global $file_list _FileReadToArray("C:\Emonitor\ftp_ls.txt", $file_list) For $n = 1 To $file_list[0] If StringMid($line, 9, 10) = "classified" Then If StringRight($line, 3) = "pdf" Then FileWrite($clean_pdf_filelist, $line & @CRLF) If StringRight($line, 3) = "xml" Then FileWrite($clean_xml_filelist, $line & @CRLF) EndIf Next FileClose($clean_pdf_filelist) FileClose($clean_xml_filelist) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now