I have the following code to read a .csv file that contains two rows of data. I do not know what is wrong with it. How can I improve it to read a .csv file with two rows of data
Here is a program that will read a CSV file with 2 rows and output both data fields. If you have more rows change the input array to be larger.
#include
#include
$file = FileOpen("test.csv", 0)
If $file = -1 Then
MsgBox(0, "error", "File doesn't exist or can't be read")
Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
Local $line = FileReadLine($file)
If @error = -1 Then ExitLoop
$input = StringSplit($line, ",")
;This is reading fields 1 and 2.
;The array index [0]
;it will tell you how big the array is.
Local $value1 = $input[1]
Local $value2 = $input[2]
ConsoleWrite("var=" & $value1)
ConsoleWrite("var=" & $value2)
WEnd