You could modify the script to use fgetcsv instead of fgets.

 

http://us2.php.net/manual/en/function.fgetcsv.php

 

------------------------------------

Robert Heath

[email protected]

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Rusty Fincke
Sent: Thursday, February 03, 2011 10:02 AM
To: [email protected]
Subject: [Refresh Austin: 5771] PHP script to import csv data into mysql

 

Hi there!  I was wondering if anyone had thoughts, pointers, links or help
on my situation.  I'm looking for a php script that will import csv data in
mysql.  I need a client to be able to upload a file (CSV) from their
computer and then have it import the CSV into MySQL.  I've found a solution
that works here: http://www.legend.ws/blog/tips-tricks/csv-php-mysql-import/


However, this doesn't allow for fields that include commas that are
contained in double quotes.  The client's CSV file might have fields that
are dollar amounts with commas in it ( $5,250 ) and it also imports a
comment field where the CSV might use a comma in the comment field.  I've
been pouring over this for some time and I just can't seem to figure out
what I need to add to this script to include for this situation.  Something
tells me it's something simple but I'm just not getting it.   FYI - I don't
need the file upload solution and code to get me to the import requirement,
I just can't get the import to work correctly when coming across fields that
include commas. 

Thought I would reach out to the refresh group and see if anyone has any
advice or dealt with this before. 

Thanks,

Rusty Fincke
[email protected]

-- 
Our Web site: http://www.RefreshAustin.org/
 
You received this message because you are subscribed to the Google Groups
"Refresh Austin" group.
 
[ Posting ]
To post to this group, send email to [email protected]
Job-related postings should follow http://tr.im/refreshaustinjobspolicy
We do not accept job posts from recruiters.
 
[ Unsubscribe ]
To unsubscribe from this group, send email to
[email protected]
 
[ More Info ]
For more options, visit this group at
http://groups.google.com/group/Refresh-Austin

-- 
Our Web site: http://www.RefreshAustin.org/

You received this message because you are subscribed to the Google Groups 
"Refresh Austin" group.

[ Posting ]
To post to this group, send email to [email protected]
Job-related postings should follow http://tr.im/refreshaustinjobspolicy
We do not accept job posts from recruiters.

[ Unsubscribe ]
To unsubscribe from this group, send email to 
[email protected]

[ More Info ]
For more options, visit this group at 
http://groups.google.com/group/Refresh-Austin

Reply via email to