Importing data from csv - Mailing list pgsql-sql

From Sumeet
Subject Importing data from csv
Date
Msg-id 7539aebb0608240747j6da083b2i3e1f380124504955@mail.gmail.com
Whole thread Raw
Responses Re: Importing data from csv
Re: Importing data from csv
List pgsql-sql
Hi Folks,<br /><br />sorry if this is a duplicate post, i've been tryin to find a solution of importing data into
postgresfrom a csv file. The problem is, I have a database which consists of columns which contain newline characters
(macand unix). now when i export these files to a csv format, there are some line breaks (mixed unix and mac) in the
datawhich breaks the copy procedure. <br /><br />I also tried using the script posted in one of the previous posts..<br
clear="all"/><br />#! /usr/bin/perl<br />$inquotes = 0;<br />while (<>){<br />     # Chop the crlf<br />     chop
($_);<br/>     chop ($_);<br /><br />     # this first bit goes through and replaces <br />     # all the commas that
renot in  quotes with tildes<br />     for ($i=0 ; $i < length($_) ; $i++){<br />         $char=substr($_,$i,1);<br
/>        if ($char eq '"' ){<br />             $inquotes = not($inquotes); <br />         }else{<br />             if
((!$inquotes) && ($char eq ",") ){<br />                 substr($_,$i,1)="~";<br />             }<br />        
}<br/>     }<br />     # this replaces any quotes<br />      s/"//g;<br />     print "$_\n";<br />}<br /><br /><br
/>catdata_file | perl scriptname.pl > outputfile.dat<br /><br />and when i run the copy command i get messages like
datamissing for xyz column.<br />any possible hints....... <br /><br />--<br />Thanks,<br />Sumeet  

pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: The length of the sql query
Next
From: Aarni Ruuhimäki
Date:
Subject: double precision vs. numeric