在postgres数值类型上导入CSV文件 [英] import csv files on postgres numeric types

查看:129
本文介绍了在postgres数值类型上导入CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将文件导入到我的Postgres数据库中并得到以下错误:

I need import a file to my Postgres database and get this error:


fabrica中的整数 1的无效输入语法;

SQL状态:22P02

invalid input syntax for integer in fabrica, "1";
SQL state: 22P02

我的命令是:

copy trazabilidade(fabrica, --integer
                    idChapa, --integer
                    descricao, --varchar
                    espessura, --double precision
                    comprimento, --double precision
                    largura, --double precision
                    peso) from 'C:/temp_nexo/traz.csv' delimiter ';';

如何从带有数字的csv文件类型中导入数据?

How can I import data from csv file types that have numbers?

推荐答案

根据Denis关于COPY命令的答复,您无法在postgres复制命令中添加自定义强制。如果pgloader过大,则可以将数据加载到临时表中,然后从那里检查,然后强制转换/修剪/操作您认为应该有效的任何数据。

As per Denis's reply about the COPY command, you can't add custom coercions to postgres copy commands. If pgloader is overkill, you can load your data to a temp table and then from there examine, then cast/trim/manipulate any data you think should be valid.

这篇关于在postgres数值类型上导入CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆