From: | Feite Brekeveld <feite(dot)brekeveld(at)osiris-it(dot)nl> |
---|---|
To: | Jonathan Hseu <vomjom(at)vomjom(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Need help with COPY |
Date: | 2001-06-17 09:33:20 |
Message-ID: | 3B2C7960.5F72BEE6@osiris-it.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Jonathan Hseu wrote:
> I want to import a table from a file. The format of the table in the file is as
> such:
> "FName","LName","Address","City"
>
> The format of the table is:
> (FName varchar(80), LName varchar(80), Address varchar(80), City varchar(80))
>
> I want to do a:
> COPY table FROM 'filename' USING DELIMITERS ','
>
> The problem is, it also imports the quotes. Also, there are sometimes commas in
> the address, and it takes those as delimiters. Is there any way to make it take
> only the stuff within the quotes and ignore any delimiters within them?
>
> Jonathan Hseu
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
reformat such input using sed:
cat yourfile | sed -e 's/"/'\''/g' >yournewfile
For readability : sed -e sq/dq/sq\sqsq/gsq in which sq = single quote dq = double
quote
Vi using regexps is also a good one.
or using perl:
while (<STDIN>) {
chomp();
s/"/'/g;
print $_, "\n";
}
Feite Brekeveld
From | Date | Subject | |
---|---|---|---|
Next Message | zilch | 2001-06-17 17:35:16 | segfault i psql |
Previous Message | Chakravarthy K Sannedhi | 2001-06-17 05:26:18 | Copy Error |