I need to be able to read a csv file.
A CSV is just a text file at the end of the day so have opened a TextStream
I need to know how I can split the line on the comma and populate the variables concerned before writing them to the database.
a typical line from the csv file would be as below
"4","South Birmingham High School","0121 687 4488"
I think i need to use InStr but can't find nuch about it am I on the correct track or is there a clearer method out there.
'Insert records from the CSV File
'Declare File access constant
Const ForReading = 1
Const TriStateFalse = 0
'Open the Text file Stream
set objFSO = server.CreateObject"Scripting.FileSystemObject"
'Using the getFile Method of objFSO,
'initialize the file Object
set filObject = objFSO.GetFile("c:\\edquest\updates\csv\CustomerRecords.csv"
'Use the OpenAsTextStream method to open the file
'for Reading and in Ascii format
filObject.OpenAsTextStream(ForReading,TriStateFalse)
'Loop around reading each line
do while not filObject.AtEndOfStream
'Use the ReadLine method to read the next line of text
'from the text file into the strBuffervariable
strBuffer = filObject.ReadLine
'Now split the variables at the comma
loop
filObject.Close
A CSV is just a text file at the end of the day so have opened a TextStream
I need to know how I can split the line on the comma and populate the variables concerned before writing them to the database.
a typical line from the csv file would be as below
"4","South Birmingham High School","0121 687 4488"
I think i need to use InStr but can't find nuch about it am I on the correct track or is there a clearer method out there.
'Insert records from the CSV File
'Declare File access constant
Const ForReading = 1
Const TriStateFalse = 0
'Open the Text file Stream
set objFSO = server.CreateObject"Scripting.FileSystemObject"
'Using the getFile Method of objFSO,
'initialize the file Object
set filObject = objFSO.GetFile("c:\\edquest\updates\csv\CustomerRecords.csv"
'Use the OpenAsTextStream method to open the file
'for Reading and in Ascii format
filObject.OpenAsTextStream(ForReading,TriStateFalse)
'Loop around reading each line
do while not filObject.AtEndOfStream
'Use the ReadLine method to read the next line of text
'from the text file into the strBuffervariable
strBuffer = filObject.ReadLine
'Now split the variables at the comma
loop
filObject.Close