I would like to import a CSV file to an array. The problem i'm facing is that I can't read a single value from a array only a whole line. If that is working then I would create a multidimensional array.
start file
test, test, test
test1, test2, test3
end file
#include <file.au3>
Dim $aRecords, $lines
If Not _FileReadToArray("error.txt",$aRecords) Then
MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
Exit
EndIf
For $x = 1 to $aRecords[0]
Msgbox(0,'Record:' & $x, $aRecords[$x])
$Columns = StringSplit($lines, ",")
for $y = 1 to $Columns[0]
MsgBox(0,"Calculate # of Dimensions", "How many: " & $y)
MsgBox(0,"Calculate # of Dimensions", "How many: " & $Columns[$y])
next
Next
aRecords[$x] contains values but then I would like to split to a single values.
But my example array $Columns[$y] doesn't even contain a value.
Second question
And after that I want to create from the two arrays one multidimensional array
I've found some code on the internet and would like to integrate my code with it and then create a multidimensional array
For example something like this : $array[linenr in file][first value on line]
$array[1][1] put on clipboard and paste in another program
Dim $lines,$Display, $NumCols
$lines = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday"
;---------------------------------------------------------------------
;Lets convert a comma delimited string into a single dimension array
;---------------------------------------------------------------------
$Columns = StringSplit($lines, ",")
$NumCols = $Columns[0]
MsgBox(0,"Calculate # of Dimensions", "How many: " & $Columns[0])
;---------------------------------------------------------------------
;Lets build a multidimensional Array with enough columns
;---------------------------------------------------------------------
Dim $array[2][ $Columns[0] ]
For $i = 1 To $Columns[0]
$array[1][$i-1] = $Columns[$i]
Next
;---------------------------------------------------------------------
;Display comma delimited string to a multidimensional Array
;---------------------------------------------------------------------
For $j = 1 To $NumCols
$Display = $Display & "array[1]["&String($j-1)&"]" & Chr(9) & " = " & chr(9) & $array[1][$j-1] & @CRLF
Next
MsgBox(4096, "Your Multidimensional Array",$Display)