I'm Sort of new, sort of old to VB I learned the old versions years back (before .net), so bare with me here. I am trying to write a script that will read the data from a CSV file and chop it up into a number of variable arrays.
CSV file looks something like this:
Uniquedata,date,data,data,data,,,,,,(and so on)
Uniquedata,date,data,data,data,,,,,,(and so on)
Uniquedata,date,data,data,data,,,,,,(and so on)
The number of lines is never the same but the number of datapoints in each line is always the same [56 datapoints]. The code below works up until I try to get the data to go from the aryTextFile() to the separate arrays[ie...SampleID()] for each data point[marked in red]. I'm sure I'm doing something stupidly simple here but I can't figure it out and I don't know what to search for to find the answer. All the variables and arrays are delcared in other areas of the code, so I don't think that is the issue.
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
Linetext = Linetext & (objReader.ReadLine() & vbNewLine)
'split data string data from linetext into array
MsgBox(Linetext)
i = 0
Dim aryTextFile() As String = Linetext.Split(",")
For i = 0 To UBound(aryTextFile) : Next i
' put arytextfile array data into type arrays
SampleID(x) = aryTextFile(i)
x = x + 1
'used to clear Linetext after each line form the csv is read
Linetext = ""
Loop
Basically, I am trying to get line1[data1], line2[data1].... into var1() , then line1[data2], line2[data2].... into var2() and so on down the file. If my code is junk and you know of an easier way to do this please let me know. but any help is appreciated.
Thanks
CSV file looks something like this:
Uniquedata,date,data,data,data,,,,,,(and so on)
Uniquedata,date,data,data,data,,,,,,(and so on)
Uniquedata,date,data,data,data,,,,,,(and so on)
The number of lines is never the same but the number of datapoints in each line is always the same [56 datapoints]. The code below works up until I try to get the data to go from the aryTextFile() to the separate arrays[ie...SampleID()] for each data point[marked in red]. I'm sure I'm doing something stupidly simple here but I can't figure it out and I don't know what to search for to find the answer. All the variables and arrays are delcared in other areas of the code, so I don't think that is the issue.
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
Linetext = Linetext & (objReader.ReadLine() & vbNewLine)
'split data string data from linetext into array
MsgBox(Linetext)
i = 0
Dim aryTextFile() As String = Linetext.Split(",")
For i = 0 To UBound(aryTextFile) : Next i
' put arytextfile array data into type arrays
SampleID(x) = aryTextFile(i)
x = x + 1
'used to clear Linetext after each line form the csv is read
Linetext = ""
Loop
Basically, I am trying to get line1[data1], line2[data1].... into var1() , then line1[data2], line2[data2].... into var2() and so on down the file. If my code is junk and you know of an easier way to do this please let me know. but any help is appreciated.
Thanks