Re: Import File

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Rodrigo Africani <rafricani(at)fotinisystems(dot)com(dot)br>
Cc: Postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Import File
Date: 2005-08-23 15:18:05
Message-ID: 20050823151805.GA9651@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 23, 2005 at 11:47:57AM -0300, Rodrigo Africani wrote:
> I'm trying to import a sequence txt file.
> The file has fix columns ... i.e the first 10 positions is the primary key ...
> The comand copy need a delimitier but the file is seq without a delimitier.
> I look in the manual but i don't won't if it is possible.
> My problem is the file is very large ... > 1G and I don't have a lot of memory
> to change the file and put delimitiers.

If you have enough disk space then you don't need a lot of memory
to change the file: simply run it through a filter that reads one
line at a time, changes it, and writes it to a new file. Such
filters are trivial to write in Perl and other scripting languages.
If you don't have enough disk space then you could pipe the filter's
output into psql and use "COPY FROM stdin" -- this might be faster
anyway because it involves less disk I/O.

--
Michael Fuhr

In response to

  • Import File at 2005-08-23 14:47:57 from Rodrigo Africani

Browse pgsql-general by date

  From Date Subject
Next Message Emi Lu 2005-08-23 15:20:04 Re: Question about Foreign key constraint causes "costly
Previous Message Michael Fuhr 2005-08-23 15:04:25 Re: Question about Foreign key constraint causes "costly sequential scans"?