Forum Moderators: phranque

Message Too Old, No Replies

How to Parse a comma delimited file

         

kevinj

3:54 pm on Aug 5, 2002 (gmt 0)

10+ Year Member



I have set up a customer of mine with Authorize.net to process credit cards online. Authorize.net returns a comma-delimited file with all the fields I need, but I am unsure how to parse the file and get the fields separated out so I can use them. Does anyone have any input on how to simply parse a comma-delimited file? Even a link to an example would be much appreciated.

Thanks.

jatar_k

4:17 pm on Aug 5, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



There is a php function that is available but I don't know what languages are available to you.

fgetcsv function [php.net]

You just open the file, with fopen [php.net] for example, use the above function in a loop reading each line and they are dumped into an array. You can then do what you want with the info. Then close the file when you are done.

It also depends what you are doind with the data. Are you going to drop it into a DB or what?

kevinj

4:34 pm on Aug 5, 2002 (gmt 0)

10+ Year Member



Once the card is approved, I'm dumping the data into my own database and sending the customer a receipt.

jatar_k

4:39 pm on Aug 5, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if you are using php the above function would work then.

Brett_Tabke

6:51 am on Aug 19, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



As Jatar said, it depends upon what language you are using. In perl:

($a,$b,$c,$e,$f,$g,$h) = split(/\,/,$CSLine);

Where $a...$h are the fields that are split apart and $CSVLine is the comma separated line.

kevinj

4:43 pm on Aug 19, 2002 (gmt 0)

10+ Year Member



I would like to use simple ASP to parse the file since that is what I have the most experience with. Any possibilities that you're aware of?

jatar_k

6:57 pm on Aug 19, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I am sorry I can't help you with the asp but there were some resources mentioned in this thread [webmasterworld.com] that may provide some answers.

aspdaddy

7:02 pm on Aug 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Kevinj,

You can use the vbScript split function to create an array from conmma delimited string. eg :

myArr=split(objTextStream.ReadAll,",")

korkus2000

7:09 pm on Aug 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



He continued the thread over here. [webmasterworld.com...]