如何导入 CSV?
我有一个如下所示的 CSV 文件:
id, name
0, A.D. TRAMONTANA
1, Abarth
2, Abbot-Detroit
3, AC
...
我正在尝试通过 phpPgAdmin 将其导入到我的表中。
它给了我这个错误:
SQL error:
ERROR: column "id, name" of relation "app_vehiclemake" does not exist
LINE 1: INSERT INTO "public"."app_vehiclemake" ("id, name") VALUES (...
^
In statement:
INSERT INTO "public"."app_vehiclemake" ("id, name") VALUES ('0, A.D. TRAMONTANA')
它看起来像是引用 "id, name"
作为一个列名称。不太确定为什么...我的 CSV 应该采用什么格式?找不到任何这方面的文档!
I've got a CSV file that looks like this:
id, name
0, A.D. TRAMONTANA
1, Abarth
2, Abbot-Detroit
3, AC
...
I'm trying to import it into my table via phpPgAdmin.
It gives me this error:
SQL error:
ERROR: column "id, name" of relation "app_vehiclemake" does not exist
LINE 1: INSERT INTO "public"."app_vehiclemake" ("id, name") VALUES (...
^
In statement:
INSERT INTO "public"."app_vehiclemake" ("id, name") VALUES ('0, A.D. TRAMONTANA')
It looks like it's quoting "id, name"
as one column name. Not really sure why... what format should my CSV be in? Can't find any documentation on this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PHP
fgetcsv()
函数,通常用于从 CSV 文件中读取一行,需要:,
作为字段之间的分隔符"
作为封装,对于每个字段的每个数据。所以也许只需将 double -每条数据都加引号可以吗?
Something like this, I'd say :
(嗯,不确定......但可能值得一试?)
The PHP
fgetcsv()
function, which is often used to read a line from a CSV file, expects :,
as a delimiter between fields"
as enclosure, for each data of each field.So maybe just putting double-quotes arround each piece of data would work ?
Something like this, I'd say :
(Well, not sure... But might be worth a try ?)