I am trying to read a CSV file with VBScript and it is causing huge problems because it isn't recognizing a line break. The way I have right now is:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(server.mappath("my_csv_file.csv"), ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrFields = Split(strLine, ",")
LOOP_STUFF_HERE
Loop
The CSV file has several lines but the problem is that it is reading the CSV file all as one long line and the last item of each line is being combined with the first item of the next line because there is no comma after the last line (it's being created by a client of mine in Excel and then sent to me). My solution is that I have to open it up in a text editor, manually add a comma to the end of the lines and then remove the line breaks. This won't work in the long run because we are setting up an automated system.
Basically, I need to be able to to Split
the lines on a line break (I've tried Split(strLine, "\n"
but that doesn't seem to work) and then once they are split by line break, then split them by comma. It'd be a multidimensional array in other words.
I can't find out how to get VBScript to recognize the line breaks though. Any ideas? Thanks for your help.