Saving CSV

  • Thread starter Thread starter grahowler
  • Start date Start date
G

grahowler

Hi

I have a question about saving CSV files from Excel. I can save a file
no problems using save as type but the thing is the text fields in the
CSV format are not wrapped in inverted commas. E.g....

1,"Some text","Some more text","","Some more, and even more, text"

I have written a php script that imports the CSV file into a database
using fgetcsv() so that users can save Excel spredsheet as CSV files
then import them into a MySQL database. The thing is though that Excel
doesn't wrap the text in inverted commas therefore the field above,
"Some more, and even more, text", breaks the fgetcsv() format.

What I am wondering is if anyone know how to force Excel to wrap text
in inverted commas or save using a different delimiter.

The only problem with using a different delimiter is that in one
instance I have a case where the last field in the CSV list may be left
blank, e.g...

1,"Some text","Some more text",""

But if it is done without inverted commas, i.e...

1,Some text,Some more text,

fgetcsv() does not register that there is a blank feild on the end of
the row at all. Thats why wrapping the text is really the answer I
need.

Thanks in advance!
 
Back
Top