-
.csv file into an array
Help...
I have a large .CSV file containing numbers only.
I can import it into a VB text box to get a string of numbers like:
2,45,623,55,3,6,,,,etc.
However I need to break the data up and put it into an array so it looks like:
2,45,623
55,3,6
,,,,,etc
Any Ideas?
-
hello
Might be a good idea to create a import spec and pass all numbers into a table. From this you could create a query to get the desired results and thus output them to your list box!
-
This should do the trick !
Code:
Dim strCSVFileText As String
Dim straryCSVFileLines() As String
Dim intCounter As Integer
intCounter = 0
Open "C:\TestCSVFile.csv" For Input As #1
Do While Not EOF(1)
ReDim Preserve straryCSVFileLines(intCounter)
Line Input #1, straryCSVFileLines(intCounter)
intCounter = intCounter + 1
Loop
Close #1
-
This is a good web site for quick code. They have just added some parse CSV code.
http://www.xbeat.net/vbspeed/index.htm