Visual Studio 2013 Lesson : Import TXT file
[Lesson 42] <<[Contents] >>[Lesson 44]
Import CSV file
Visual Studio features a command line that allows data to
be imported rom various file types.
Streamreader reads the files and adds the data to
assigned objcets, strings or arrays. In the example the
loop continues for the number of rows in the CSV
(While Not ioReader.EndOfData)
The coding shown imports a CSV (Comma Separated value) Note the
data in the text file is separated to smaller strings
using the (,) comma.
The following coding imports a CSV file,assigns each
celi form each row in the CSV, assigns it to a string.
This string could then be assigned to an array.
'pass the file path and the file name to the
StreamWriter Constructor
objStreamWriter = New StreamWriter("G:\##Visual Studio
3013\CSV array Visual Studio - working on Calculation -
Copy\TestFile.csv", True) 'True appends file, False
overwrites file
'write to file
objStreamWriter.WriteLine(arrNumTickets(i) + "," +
arrMemNumber(i) + "," + arrCode(i) + "," +
arrMethodSale(i)) 'Can just use .write
' close the file
objStreamWriter.Close()