'Upload CSV file into postgresql
I am trying to upload a CSV file into PostgreSQL and I get this error message: ERROR: invalid byte sequence for encoding "UTF8": 0xa0 CONTEXT: COPY employees, line 95 SQL state: 22021 First I create the table:
Create table employees (EMPLOYEE_ID int, NAME varchar (100), TITLE varchar (100), JOBFAMILY varchar (5), RC int, TMREG numeric(1000,2),TMNONREG numeric(1000,2), PUGET numeric(1000,2), EDS numeric(1000,2), HOLDCO numeric(1000,2),TMEP numeric(1000,2), Total numeric(1000,2), CATEGORY int, TMEPDED varchar(3), ACTIVITY varchar(100))
Then I try to pull the data:
COPY employees (EMPLOYEE_ID, NAME, TITLE, JOBFAMILY, RC, TMREG, TMNONREG, PUGET, EDS, HOLDCO, TMEP, Total, CATEGORY, TMEPDED, ACTIVITY)
FROM 'C:\Jorge\Project\Source\employees.csv'
DELIMITER ','
CSV HEADER;
and I get the above error message. Any help please? JOrge
Solution 1:[1]
Use this:
COPY employees (EMPLOYEE_ID, NAME, TITLE, JOBFAMILY, RC, TMREG, TMNONREG, PUGET,
EDS, HOLDCO, TMEP, Total, CATEGORY, TMEPDED, ACTIVITY)
FROM 'C:\Jorge\Project\Source\employees.csv'
DELIMITER ','
NULL
CSV HEADER;
You would also have to specify Null as columns in the csv.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | nikhil sugandh |
