DrewSS Posted July 3, 2014 Share Posted July 3, 2014 (edited) Hello, I'm trying to get the second part my script starting with Local $GS1 to loop for the array $aArray, but it is only running once. What is the syntax or formatting i'm getting wrong? #include <Excel.au3> #include <Array.au3> #include <File.au3> $sFilePath1 = @ScriptDir & "\rebindtest.xls" ; source targets $sFilePath2 = @ScriptDir & "\test.txt" ; destination target $oExcel = _ExcelBookOpen($sFilePath1) ; open excel sheet $aArray = _ExcelReadSheetToArray($oExcel) ; turns excel content into array For $results = 0 To UBound($aArray) - 1 ; loops excel columns to copy files from 1 format into .ini format $chain = $aArray[$results][1] ; column 1 is chain names $store = $aArray[$results][2] ; column 2 is store names FileCopy(@ScriptDir & "\testsource\st" & $store & 'in.' & $chain, @ScriptDir & "\testinis\" & $chain & "-" & $store & ".ini") ;copies stSSSSin.CCC into CCC-SSSS.ini to be used for IniReadSection Next Local $GS1 = IniReadSection(@ScriptDir & "\testinis\" & $chain & "-" & $store & ".ini", "Group1") ; copies Group1 section the content from .ini file into a .txt file For $Group1 = 1 To $GS1[0][0] ; Loops the whole Group1 section into 2 colums (key, and value) FileWrite($sFilePath2 , $GS1[$Group1][0] & " " & $GS1[$Group1][1] & @LF) ; Writes the key and values into a text file. Next _ExcelBookClose($oExcel) The File copy works correctly, but FileWrite only write the last of the .ini files into the text file. Edited July 3, 2014 by DrewSS Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 3, 2014 Moderators Share Posted July 3, 2014 Unless I am misunderstanding, you want to do your IniReadSection on each file, right after you copy it, right? To do so, you would want to add the $GS1 piece into the outer For loop, something like this: #include <Excel.au3> #include <Array.au3> #include <File.au3> $sFilePath1 = @ScriptDir & "\rebindtest.xls" ; source targets $sFilePath2 = @ScriptDir & "\test.txt" ; destination target $oExcel = _ExcelBookOpen($sFilePath1) ; open excel sheet $aArray = _ExcelReadSheetToArray($oExcel) ; turns excel content into array For $results = 0 To UBound($aArray) - 1 ; loops excel columns to copy files from 1 format into .ini format $chain = $aArray[$results][1] ; column 1 is chain names $store = $aArray[$results][2] ; column 2 is store names FileCopy(@ScriptDir & "\testsource\st" & $store & 'in.' & $chain, @ScriptDir & "\testinis\" & $chain & "-" & $store & ".ini") ;copies stSSSSin.CCC into CCC-SSSS.ini to be used for IniReadSection Local $GS1 = IniReadSection(@ScriptDir & "\testinis\" & $chain & "-" & $store & ".ini", "Group1") ; copies Group1 section the content from .ini file into a .txt file For $Group1 = 1 To $GS1[0][0] ; Loops the whole Group1 section into 2 colums (key, and value) FileWrite($sFilePath2 , $GS1[$Group1][0] & " " & $GS1[$Group1][1] & @LF) ; Writes the key and values into a text file. Next Next _ExcelBookClose($oExcel) If this is not correct, can you please explain in more detail what you would like to do step by step? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
wisem2540 Posted July 3, 2014 Share Posted July 3, 2014 Is it possible to post the files you are using so I can run this? Link to comment Share on other sites More sharing options...
DrewSS Posted July 3, 2014 Author Share Posted July 3, 2014 Hi, Thanks for taking the time... I've attached the files, but I had to edit the content to be used for example. The script should grab a list of "store and chain" numbers as represented in 2 column excel sheet, with the store and chain numbers, it copies files into a .ini format. With the new .ini files, I want it to grab section "group1" and paste it into "test.txt" for each store in the original array (i.e. all the store and chains files). test.ziptest2.au3 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