millisys Posted August 22, 2014 Share Posted August 22, 2014 Hey folks, I am trying to create a new array from an existing array by adding/inserting values from the existing 20 column 2D array into a new 2 column 2D array if the row/column cell contains a value. My thought was that I could use _ArrayAdd to add the first column into the new array, and then _ArrayInsert to insert data into the second column in the same row. The script that I have written is not inserting the data into the second column of the new array. local $y _FileReadToArray("students.csv",$aArray,0,",") Local $aArray2[0][2] for $x = 1 to ubound($aArray)-1 if StringLen($aArray[$x][22]) Then $y += 1 _ArrayAdd($aArray2, $aArray[$x][11], 0) _ArrayInsert($aArray2, $y, $aArray[$x][22],1) EndIf Next Your help is appreciated. Thank you. Link to comment Share on other sites More sharing options...
Gianni Posted August 23, 2014 Share Posted August 23, 2014 try to use $aArray2[$y][1] = $aArray[$x][22] instead of _ArrayInsert($aArray2, $y, $aArray[$x][22],1) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
millisys Posted August 23, 2014 Author Share Posted August 23, 2014 Hi Chimp, thank you for your reply. I replaced the line and received the following error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aArray2[$y][1] = $aArray[$x][22] ^ ERROR Link to comment Share on other sites More sharing options...
Solution Gianni Posted August 23, 2014 Solution Share Posted August 23, 2014 move $y += 1 after $aArray2[$y][1] = $aArray[$x][22] Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
millisys Posted August 23, 2014 Author Share Posted August 23, 2014 Sweet! Awesome Chimp. I forgot - the first row is 0 not 1. Thank you! Link to comment Share on other sites More sharing options...
Gianni Posted August 23, 2014 Share Posted August 23, 2014 you're welcome Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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