Hey so I ran into a pretty big problem here and hoping someone could lend some advice.
Scenario:
-
User uploads CSV file to server through ASP form (Check)
-
ASP then reads that file parses it throws in a HTML table for user to preview (Check)
-
Throw headers and body columns into 2 seperate array to store for database saving capability (Check)
-
If user has a “,” in the header name or a field entry things go crazy! (Check)
That’s the process and all is great except if there is a comma in one of the field entries or in the header names.
For example:
This is good:
Dave, Collier, 555 Fake Street, Washington Gardens, NJ, 07882
This is bad
Dave, Collier, 555 Fake Street, Washington, Gardens, NJ, 07882
What happens is it thinks gardens should be it’s own array element. Logically is what I am trying to do possible? I don’t see how.
Here’s some sample code
set fso = createobject("scripting.filesystemobject")
set act = fso.opentextfile(server.mappath(databaseName))
imported_text = act.readline
imported_text = replace(imported_text,chr(13),",")
imported_text = replace(imported_text,chr(34),"")
split_text=split(imported_text,",")
num_imported=ubound(split_text)+1
total_imported_text = act.readall
total_imported_text = replace(total_imported_text,", "," ")
total_imported_text = replace(total_imported_text,chr(13),",")
total_imported_text = replace(total_imported_text,chr(34),"")
total_split_text=split(total_imported_text,",")
total_num_imported=ubound(total_split_text)
for i=1 to uBound(split_text)
Response.Write "<br>" & (i) &". " & split_text(i)
Next
Note there is no user input this funcitonality should work for any database(csv) supplied. Any logic input would be great.
Thanks so much!