igorm Posted August 12, 2008 Share Posted August 12, 2008 Hi, I have a 2 arrays which sometimes contain up to 4165 elements. I need to write all those elements to text file. I'm using this: $array1 = stringsplit($mydata1, "=") $array2 = stringsplit($mydata2, "=") Arrays have same numbers of elements so next part of code is this: for $i=1 to array1 [0] iniwrite("textfile.txt", "File", array1[$i], $array2[$i]) next This works fine, but it's painfully slow. Is there any way I can speed this up, or there is some other way I can export all data from array to text file? Exported text file needs to have INI file form: [File] Key=Value Thanks in advance for any help. Cheers Office 2000/XP/2003/2007 Slipstreamer Link to comment Share on other sites More sharing options...
DjDeep00 Posted August 12, 2008 Share Posted August 12, 2008 @igorm...Try _FileWriteFromArray(). Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 12, 2008 Share Posted August 12, 2008 Hi, I have a 2 arrays which sometimes contain up to 4165 elements. I need to write all those elements to text file. I'm using this: $array1 = stringsplit($mydata1, "=") $array2 = stringsplit($mydata2, "=") Arrays have same numbers of elements so next part of code is this: for $i=1 to array1 [0] iniwrite("textfile.txt", "File", array1[$i], $array2[$i]) next This works fine, but it's painfully slow. Is there any way I can speed this up, or there is some other way I can export all data from array to text file? Exported text file needs to have INI file form: [File] Key=Value Thanks in advance for any help. Cheers What takes so long in the many iterations of Open/Write/Close on the file. If you assemble it all as a string in memory and then write it once, it will be very fast: $sIniFile = "TestFile.txt" $sIniData = "[File]" & @CRLF for $i=1 to $array1[0] $sIniData &= $array1[$i] & "=" & $array2[$i] & @CRLF next FileWrite($sIniFile, $sIniData) The _FileWriteFromArray() suggestion won't work because you are assembling data from two arrays into INI format. 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...
DjDeep00 Posted August 12, 2008 Share Posted August 12, 2008 (edited) The _FileWriteFromArray() suggestion won't work because you are assembling data from two arrays into INI format.My bad...you are 100% correct... Dyslexia Edited August 12, 2008 by DjDeep00 Link to comment Share on other sites More sharing options...
igorm Posted August 12, 2008 Author Share Posted August 12, 2008 Thank you very much PsaltyDS, much faster now. Cheers Office 2000/XP/2003/2007 Slipstreamer 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