Jump to content
Sign in to follow this  
millisys

Creating a new Array from existing Array using _ArrayAdd and _ArrayInsert

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...