0

I make table:

CREATE TABLE data (
date    date,
time    time,
val3    float,
val4    float);

And trying to load csv to it with next command:

copy data from 'G:\test\1.txt' DELIMETERS ' ' CSV;

the CSV have same structure:

date time val3 val4 
2012.08.10 06:53:18 695.417 773.29

But I am getting next error:

ERROR: invalid input syntax for type date: "date"

Could you help me to find the reason of error?

2 Answers 2

1

I'm not very used to postgres, but I think you should set your datestyle before importing your file :

set datestyle German, YMD;

Look at these links : How do I alter the date format in Postgres? and DateTime Output

Sorry if I'm wrong, but I think you have to correctly set your datestyle (you can also do in the postgres.cnf file).

2
  • 1
    It is better to use links to current version of postgres manual. /docs/current/static instead of /docs/8.2/static. Jul 22, 2013 at 12:40
  • I had tried this command several times. It does not work with quote symbol. Plz look at my log postimg.org/image/51n25xr0z Jul 22, 2013 at 12:51
0

Do you have a header line in your CSV? If so, try

copy data from 'G:\test\1.txt' DELIMETERS ' ' CSV HEADER;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.