Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV Format

Status
Not open for further replies.

dwhalen

Programmer
Feb 22, 2002
105
CA
I know this may not really be a postgres question per se but I am using a postgres database so I guess that gives me an excuse to ask in this form :).

I am using perl and postgres to make some reports for a client but they want me to print results to a file in csv format. I am having trouble finding out what the standard CSV format is. And I think Microsoft may have a different vision of what that is. I assumed that CSV was a comma separated line with each column inclosed in single quotes ' and all single quotes inside each single quote prefixed with a backslash. Am I correct? Does anyone know where I can get documentation on this?

example:
'col1','col2','col\'3'
'row2','row2','row2'

Thanks
 
All the csv files I handle are comma delimited w/no quotes of any kind. I know that when you save a file from Excel as a CSV you have the option of adding quotes to identify text as opposed to numbers. Personally I hate when the quotes are added - as it makes me deal w/them in code. I'd rather they weren't there and if any formatting needs to be done w/certain fields I handle it.
 
Thanks for your help. That seems to be what everyone is telling me.

Later
 
In my experience, the standard quoting style for CSV is:

1. No quotes for numeric columns, just commas
2. Full ("double") quotes for text, date, etc... with all double quotes inside the fields escaped as \". This is known as "optional" quoting, since most products that deal with CVS do this automatically.

Obviously, with PostgreSQL, you can use anything for your column separator, and as long as the style is consistent, most microsoft products allow you to choose your separators upon import. -------------------------------------------

Big Brother: "War is Peace" -- Big Business: "Suspicion is Trust"
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top