I would like to import a large R data.frame object into Postgres. I am saving the object as a CSV file using these commands:
> out_file <- paste(input_path, "data.csv", sep="")
> con<-file(out_file, encoding="UTF-8")
> write.csv(df, out_file)
No error messages are shown. Then switching to psql I issue the import with COPY, which results in this error:
# COPY data_in FROM 'data.csv' DELIMITER ',' CSV HEADER;
ERROR: invalid byte sequence for encoding "UTF8": 0xf8
CONTEXT: COPY data_in, line 74358
Which software is failing here? Or is more guidance needed to get the correct encoding?
write.csv(df, out_file,fileEncoding=TRUE)orwrite.csv(df, con). You are using the file path despite creating a connection object