0

Here is my code in reading csv file using asp. But I'm having a problem if there is a comma within the field.

Set objFSO = CreateObject("Scripting.FileSystemObject")

'*** Check Exist Files ***'
If Not objFSO.FileExists(Server.MapPath(sFileName)) Then
Response.write("File not found.")
Else

'*** Open Files ***'
Set oInStream = objFSO.OpenTextFile(Server.MapPath(sFileName),1,False)

Do Until oInStream.AtEndOfStream
sRows = oInStream.readLine
arrRows = Split(sRows,",")

response.write(arrRows(0))
response.write(arrRows(1))
Loop
oInStream.Close()
Set oInStream = Nothing

End IF
Elish Torres
  • 35
  • 1
  • 6
  • Read this: http://blogs.technet.com/b/heyscriptingguy/archive/2008/06/16/how-can-i-remove-specified-commas-from-a-comma-separated-values-file.aspx – Jen R Apr 21 '15 at 17:08
  • 1
    One possible way round this is to use the JET OLEDB data provider to connect to your csv file as if it is a database, see http://stackoverflow.com/questions/213657/how-to-read-csv-files-line-by-line-in-vbscript – John Apr 21 '15 at 17:42

0 Answers0