dbTalk Databases Forums  

Re: copy - fields enclosed by, ignore x lines

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Re: copy - fields enclosed by, ignore x lines in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pierre-Frédéric Caillaud
 
Posts: n/a

Default Re: copy - fields enclosed by, ignore x lines - 10-25-2004 , 05:55 PM







Use python's (or another language) CSV reader module which will parse the
quotes for you and write the values in a tab-delimited file. Don't forget
to escape the tabs in the strings... it should be less than 10 lines of
code.

On Mon, 25 Oct 2004 14:45:57 -0700 (PDT), CSN
<cool_screen_name90001 (AT) yahoo (DOT) com> wrote:

Quote:
Any chance of changing \copy and COPY to allow
specifying what the fields are enclosed by (such as
quotes) and to ignore the first x number of lines? I
have data like below and don't know of an easy way to
finesse it for importing (a simple regexp would remove
quotes, but I just got tripped up on commas *within*
values).

"field1","field2","field3"
"val1","val2","val3"



__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.