0

This is my first time with pgloader, I'm trying to load a CSV file to my ddbb, and I'm receiving an error that I can't solve. This is my code:

 LOAD CSV
    FROM 'csvload.csv' WITH ENCODING UTF-8
        HAVING FIELDS
        (
            id,
            long,
            lat,
            time [date format 'YYYY-MM-DD'], 
            pacde, 
            varty, 
            value, 
            magde, 
            mod, 
            created
        )
    INTO postgresql://postgres:pass@localhost:5432/name_tab
        TARGET TABLE csv_load
        TARGET COLUMNS
        (
            long, 
            lat, 
            time, 
            pacde, 
            varty, 
            value, 
            magde, 
            mod, 
            created
        )
    
    WITH truncate,
        skip header = 1,
        fields optionally enclosed by '"',
        fields escaped by double-quote,
        fields terminated by ';';

error 22P02: invalid input syntax for type integer: "1.0"

The values in the value column are like this "1.0" or "0.0" integer type in the ddbb. I tried to put a CAST COMMAND like this:

LOAD CSV
    FROM 'csvload.csv' WITH ENCODING UTF-8
        HAVING FIELDS
        (
            id,
            long,
            lat,
            time [date format 'YYYY-MM-DD'], 
            pacde, 
            varty, 
            value, 
            magde, 
            mod, 
            created
        )
    INTO postgresql://postgres:pass@localhost:5432/name_tab
        TARGET TABLE csv_load
        TARGET COLUMNS
        (
            long, 
            lat, 
            time, 
            pacde, 
            varty, 
            value, 
            magde, 
            mod, 
            created
        )
CAST column value to int using truncate;
    WITH truncate,
        skip header = 1,
        fields optionally enclosed by '"',
        fields escaped by double-quote,
        fields terminated by ';';

but I receive this error:

In context COMMAND. Expected:
the character Tab
or the character Newline
or the character Return
...
an unhandled error condition has been sinalled: At

)
CAST column value to int

I tried to put the closing line with , and ; but it still doesn't work, well I don't know if that's really the problem.

user68481
  • 9
  • 2

0 Answers0