Visual Studio 2013 Lesson : Import TXT file
[Lesson 41] <<[Contents] >>[Lesson 43]
Import TXT file (alternate method)
Visual Studio features a command line that allows data to
be exported from arrays or strings itoan external file.
Streamreader reads the data in the arrays or strings, and adds the data to
assigned columns or string of data in atext or CSV file. strings or arrays.
The coding shown exmports CSV file. Note the
data in the text file or cloumns in teh CSV are
identified
using the (,) comma.
The following coding exmports a CSv file to 3 columns.
'pass the file path and the
file name to the StreamWriter Constructor
objStreamWriter = New
StreamWriter("C:\MyDocuments\TestFile.csv", True) 'True
appends file, False overwrites file
'write to file
objStreamWriter.WriteLine(Array1(i) + "," + Array2(i) +
"," + Array3(i) + "," + Array4(i))
'Can just use .write
' close the file
objStreamWriter.Close()