# \[ASP\]Parsing a CSV file

**URL:** https://forum.kirupa.com/t/asp-parsing-a-csv-file/218588
**Category:** programming
**Created:** [March 9, 2007, 12:55am UTC](https://forum.kirupa.com/t/asp-parsing-a-csv-file/218588 "2007-03-09T00:55:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Digitalosophy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/digitalosophy/32/1114_2.png) [@Digitalosophy](https://forum.kirupa.com/u/Digitalosophy)
#### Post date: [March 9, 2007, 12:55am UTC](https://forum.kirupa.com/t/asp-parsing-a-csv-file/218588/1 "2007-03-09T00:55:24Z")

</div>

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

```auto

            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!
