Re: Data loading from a flat file...

From: Angshu Kar <angshu96(at)gmail(dot)com>
To: Pandurangan R S <pandurangan(dot)r(dot)s(at)gmail(dot)com>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Data loading from a flat file...
Date: 2006-01-06 06:44:09
Message-ID: df8328740601052244l240044f0g1318c1c9f7f99bdc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the chmod command Pandu but the cat command is not doing
anything!

And as Michael suggested that file has indeed carriage returns embedded in
fields. I opened it in my windows m/c using textpad and got:

B1
C1
E1
B2
C2
E2
.
.
.

Any more suggestions on how to solve this? :(

On 1/6/06, Pandurangan R S <pandurangan(dot)r(dot)s(at)gmail(dot)com> wrote:
>
> To get rid of ^M characters you could use
>
> cat file | tr -d ^M
>
> you need to type ^V before you type ^M in the preceeding command. But
> ^V will not be displayed on the screen.
>
> You might need to change directory permission too.
>
> use chmod +rx <username>.
>
> For this command to succeed you need to execute this command as root
> or the owner of the directory
>
> On 1/6/06, Angshu Kar <angshu96(at)gmail(dot)com> wrote:
> > Thanks Michael.
> >
> > I'm using PgAdmin III 1.4.0 from my WinXP m/c to access the DB in my
> linux
> > m/c! The file has about 2GB data.It returns back to the prompt very
> soon.
> > I'm using less or vi command to view the file and getting those ^M as
> > mentioned (i.e. between fields). Any clue how I can massage the data? If
> you
> > suggest I can try and write the script.
> >
> > Also, now I'm facing another permission related problem!It's throwing
> the
> > error:
> > ERROR: could not open file "/home/akar/final.out" for reading:
> Permission
> > denied
> > I've changed the file owner to postgres but without any avail!Also do I
> > need to change the permission to akar directory? How(I'm a linux
> freshie)?
> >
> > Thanks,
> > Angshu
> >
> >
> >
> > On 1/5/06, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
> > > On Thu, Jan 05, 2006 at 11:04:16PM -0600, Angshu Kar wrote:
> > > > Thanks Jim. the statement is running without any error but nothing
> is
> > > > getting copied into the table!
> > >
> > > What client are you using and what's the exact command you ran?
> > > Does the command finish or does it never return? How much data
> > > is there? What version of PostgreSQL are you using and on what
> > > platform?
> > >
> > > > Also, my data file is showing some ^M chars like
> > > >
> > > > B1^M C1^M E1
> > > > B2^M C2^M E2
> > >
> > > The ^M sequence might represent a carriage return -- how are you
> > > viewing the file to see these characters? Are they between fields
> > > as shown or only at the ends of lines?
> > >
> > > > Is it creating any trouble for the COPY command?
> > >
> > > Possibly; you might need to massage the data if you can't get COPY
> > > to read it. That should be an easy job for a script (somebody here
> > > can probably help).
> > >
> > > > And can we use INSERT with COPY?
> > >
> > > To use INSERT you'd need to read the data and generate the appropriate
> > > INSERT commands; that's another scripting job.
> > >
> > > --
> > > Michael Fuhr
> > >
> >
> >
> >
> > --
> > Ignore the impossible but honor it ...
> > The only enviable second position is success, since failure always comes
> > first...
>

--
Ignore the impossible but honor it ...
The only enviable second position is success, since failure always comes
first...

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Aaron Koning 2006-01-06 06:44:38 Re: Adding another primary key to a populated table
Previous Message Pandurangan R S 2006-01-06 06:33:11 Re: Data loading from a flat file...