Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with delimiter

Status
Not open for further replies.

MKitty

Programmer
Feb 29, 2008
4
PT
Hi!

I´ve been trying to copy data delimited with '|' from a file to a table (bulk loading).

For example, the file (nation.tbl) has this data (rows):

23|UNITED KINGDOM|3|fluffily regular ...|
24|UNITED STATES|1|blithely regular...|

The rows have always the delimiter '|' in the end and when i try to copy that data i get this error "ERROR: extra data after last expected column". I´m using this sql code:
"COPY nation FROM 'C:/nation.tbl' USING DELIMITERS '|';".

Does anyone knows how to solve this problem?

Best Regards
 
Hi

Well, then remove the trailing pipe ( | ). On Linux we would simply run one of the following from command line before executing the [tt]copy[/tt] :
Code:
sed -i 's/|$//' nation.tbl

[gray]# or[/gray]

awk '{sub(/\|$/,"")}1' nation.tbl > nation2.tbl

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top