Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

postgresql - ERROR: could not stat file "XX.csv": Unknown error

I run this command:

COPY XXX FROM 'D:/XXX.csv'  WITH (FORMAT CSV, HEADER TRUE, NULL 'NULL')

In Windows 7, it successfully imports CSV files of less than 1GB.

If the file is more then 1GB big, I get an “unknown error”.

[Code: 0, SQL State: XX000]  ERROR: could not stat file "'D:/XXX.csv'  Unknown error

How can I fix this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can work around this by piping the file through a program. For example I just used this to copy from a 24GB file on Windows 10 and PostgreSQL 11.

copy t(c,d) from program 'cmd /c "type x:pathofile.txt"' with (format text);

This copies the text file file.txt into the table t, columns c and d.

The trick here is to run cmd in a single command mode, with /c and telling it to type out the file in question.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...