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?

Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145

2 Answers2

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).

Community
  • 1
  • 1
kmas
  • 6,401
  • 13
  • 40
  • 62
0

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

copy data from 'G:\test\1.txt' DELIMETERS ' ' CSV HEADER;
bma
  • 9,424
  • 2
  • 33
  • 22