Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27351

Filling arrays from csv files

$
0
0
I'm just new so don't laugh :P It's prolly easy but I'm confused.
I've got a CSV file that I need to import run through some tests and then output to another csv file.
So far I've just got the basics

Public Shared Sub Main()
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("C:\Bepoz\Data\TTimp.csv")
Dim line As String
Dim sales_data As String
' Read and display the lines from the file until the end
' of the file is reached.

sr.Peek()
line = sr.ReadToEnd()
line.Split(",")
sales_data = (line)

sr.Close()
' Write each directory name to a file.
Dim sw As StreamWriter = New StreamWriter("c:\bepoz\data\ttexp.csv")
Dim write As String
write = (sales_data)
sw.Write(sales_data)
sw.Close()

I want to be able to fill it to an array for checks. I had sales_data(5) as string but it comes up with an error - you can't convert a string to a 1 dimensional array.

I thought if line was split and then sales_data = line after the fact it would be able to be split into an array. What am I missing?

Viewing all articles
Browse latest Browse all 27351

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>