Re: convert text file to database

From: "Szentpali Janos" <ianus(at)easynet(dot)ro>
To: e-letter <inpost(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: convert text file to database
Date: 2008-04-22 10:03:30
Message-ID: 20080422100050.M37253@easynet.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> I amended a copy of my csv files as follows:
>
2,OnlineGame,wwwflyordiecom,yyyy/mm/dd,1,player1,player2,0-1,normal,yyyy/mm/dd,1200,1d4d5...33Bf3Rxe50-1
>
3,OnlineGame,wwwflyordiecom,yyyy/mm/dd,1,player1,player2,0-1,normal,yyyy/mm/dd,1,player1,player2,1200,1e4d52e5d4...Nxf2#0-1
> Compared to my original csv file, I had to remove the field names that...

You can insert the full url with no special formating needed if you respect
the csv standard: it says strings should be enclosed in pairs of double quote
characters. So if you change

2,OnlineGame,wwwflyordiecom,yyyy/mm/dd,1,player1,player2,0-1,normal,yyyy/mm/dd,1200,1d4d5...33Bf3Rxe50-1
to

2,"OnlineGame","http://www.flyordie.com/","yyyy/mm/dd",1,"player1","player2","0-1","normal","yyyy/mm/dd",1200,"1d4d5...33Bf3Rxe50-1"

it will work. You can use other characters than double quote (") for string
delimiters; in that case you should use the QUOTE option of the CSV option to
specify the new string delimiter. If a string delimiter exists in the string,
it can be "escaped" by doubling it:

x said "Go away"

could be written as

"x said ""Go away"""

--
Szentpáli János

--------------------------------------------------

easynet.ro - Best free webmail service hosted by Idilis
.........................................................
Idilis - Internet Provider :: www.idilis.net
Inchiriem conexiuni radio si in zone neracordate la coloana - Broadband Wireless Idilis -

Browse pgsql-novice by date

  From Date Subject
Next Message Nils Zierath 2008-04-22 12:46:03 Re: Remote / network connection fails
Previous Message Nils Zierath 2008-04-22 09:41:49 Re: Remote / network connection fails