LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 04-15-2011, 01:14 PM   #1
Learnix
Member
 
Registered: Jan 2011
Location: Montreal,Qc,Canada
Distribution: Debian/GNU
Posts: 34

Rep: Reputation: 0
Postgresql 8.47.on Debian/ Gnu Squeeze-stable. Imporitng data


Hi,
I imported one table from a csv file format with no problems.
The file fields where matching my table fields.

*** For a second table import (I will use a similar example to simplify:

--- So I created a table with the following fields:

Contactname addr city zipcode

the file to import has the following fields

Contactname firstname middlename lastname addr city zipcode.

Is there a way to import the file by listing the columns
I tried :
copy MyTableName column(contactname,,,,addr,city,zipcode) from 'pathtomycsvfile' with null as '' csv header quote as '"' escape as '"' ;
The error is always pointing to the 'c' of column I tried to remove the parenthesis I removed the statement 'column' and other scenarios
It Didn't work.
Does that mean that I will absolutely have to remove those unwanted columns from the import file. I have about 120 of those files to import.
If I can avoid to do the later what would be the right statement.

Cheers,
 
Old 04-15-2011, 08:05 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
There are two problems here:

a) You're using a column keyword that doesn't exist; what you'd want
to do normally is:
Code:
copy MyTableName (contactname,addr,city,zipcode) from 'pathtomycsvfile' with null as '' csv header quote as '"' escape as '"' ;
b) You can't import parts of a csv; every column in the CSV must
be matched in your table structure. Look at PGLoader, or sanitise
your data ...


Cheers,
Tink
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Two days till Debian Squeeze goes Stable LXer Syndicated Linux News 0 02-04-2011 10:31 PM
LXer: Debian Squeeze set for Stable release on Feb. 5 or 6 - it's a distro you shouldn't ignore LXer Syndicated Linux News 0 01-21-2011 04:30 AM
LXer: Debian Squeeze cleans up the grub2 wallpaper in desktop-base, and we're a bit closer to Stable LXer Syndicated Linux News 0 01-05-2011 12:01 AM
[SOLVED] Waiting for Squeeze stable vs installing Squeeze right now and keeping it up to date alanv Linux - Newbie 2 11-03-2010 03:43 AM
Java error - Debian GNU/Linux 6.0 Squeeze/sid DebianUserfg Linux - Newbie 2 05-31-2010 08:00 PM


All times are GMT -5. The time now is 08:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration