[portland] Reformatting Data Files

Ethan Furman ethan at stoneleaf.us
Tue Feb 1 22:18:34 CET 2011

Rich Shepard wrote:
>   What I still need to figure out is why csv.writer() is not writing proper
> delimited output. Here's an example of output lines:
> JCM-20B,2008-11-13,Depth to Water,97.08
> JCM-20B,2008-11-13,pH,7.40
> JCM-20B,2008-11-13,Total Dissolved Solids,211
> JCM-20B,2008-11-13,"Alkalinity, Bicarbonate",167
>   Notice that the third item is not quoted unless the text contains a 
> comma.
> What I want for output is to have all text fields (that is, all but the 
> last
> one) quoted, preferably with single quotes to keep postgres happy.


Try adding quoting=csv.QUOTE_NONNUMERIC to your writer invocation.


More information about the Portland mailing list