Unix Technical Forum

problems with copy

This is a discussion on problems with copy within the pgsql Sql forums, part of the PostgreSQL category; --> I'm getting lots of delimited files from Excel and MySQL users that, mid-file, begin truncating lines if ending in ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 05:55 PM
chester c young
 
Posts: n/a
Default problems with copy

I'm getting lots of delimited files from Excel and MySQL users that,
mid-file, begin truncating lines if ending in null values.

for example:
1781: "one","two","three",,,,,,
1782: "one","two","three",,
1783: "one","two","three",,

(delimited files from Open Office are well behaved)

is there any way to handle this apparently standard aberration in PG?



__________________________________________________ __________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yah...invite.asp?a=7


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 05:55 PM
Luis Carlos Ferreira
 
Posts: n/a
Default Re: problems with copy

El Lun 24 Sep 2007 21:38, chester c young escribió:
> I'm getting lots of delimited files from Excel and MySQL users that,
> mid-file, begin truncating lines if ending in null values.
>
> for example:
> 1781: "one","two","three",,,,,,
> 1782: "one","two","three",,
> 1783: "one","two","three",,
>
> (delimited files from Open Office are well behaved)
>
> is there any way to handle this apparently standard aberration in PG?
>

You need to normalize the csv files filtering its contents with some script
....
....
$fields_in_table=9;
while (<>) {
chomp;
@f=split(",");
for $i ( 0 .. $fields_in_table ) {
print $f[$i].",";
};
print "\n";
};
....
....

--

Luis

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com