在postgress数字类型上导入csv文件 [英] import csv files on postgress numeric types

查看:408
本文介绍了在postgress数字类型上导入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.

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

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