如何更改 mysql 中导入电子表格的数据类型?
我已将美国政府统计数据的电子表格导入到 mysql 表中,目的是完成教程。
然而,美国政府似乎改变了格式,将一些数字用引号括起来,将它们变成字符串。
例如,这是我应该下载的制表符分隔数据的格式:
CN010010 01 001 "Autauga County, AL" 2005 23831 23061 770 3.2
但是,它看起来像这样: CN010010 01 001 "Autauga County, AL" 2005 "23,831 " "23,061 " 770 3.2
结果,我想要作为整数导入的两个关键数据列(23831 和 23061 位)注册为 0 - 可能是因为它不符合数据类型。
现在和将来解决这个问题的最佳解决方案是什么?
提前致谢。
I've imported a spreadsheet of U.S. Government statistics into a mysql table with the aim of working through a tutorial.
However, it would appear that the U.S. Government has changed its formatting so that some of numerical figures are wrapped in quote marks, turning them into strings.
For example, this is the format of the tab-separated data that I'm supposed to have downloaded:
CN010010 01 001 "Autauga County, AL" 2005 23831 23061 770 3.2
However, it looks like this: CN010010 01 001 "Autauga County, AL" 2005 "23,831 " "23,061 " 770 3.2
As a result the two key columns of data (the 23831 and 23061 bits) that I want to import as integers are registering as 0 - presumably because it doesn't meet the data type.
What's the best solution for resolving this problem, now and in the future?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“逗号”可能会引起问题。您是否为此使用加载数据文件?
假设表定义:
以下将导入文件:
将插入以下行:
The "comma" might cause problem. Are you using load data infile for this?
Assuming table definition:
The following would import the file:
would insert the following row: