dongliao3450 2013-12-13 15:22
浏览 53

使用phpMyAdmin将使用长数字的电子表格导入MySQL的最佳方法

I have recently been collecting data for my company to create a MySQL database. In doing this using PHP it can be used to view, add, edit and delete using a webpage interface.

I have currently created a prototype that allows me to import this data by converting a .XLS or XLSX sheet into a .CSV format that is then imported through PHPMyAdmin. Only recently I have found a snag with using this method. In my spreadsheet I have a few columns that represent barcodes, these barcodes vary in size, some going over 15 digits long. Excel has a limit to what it will represent and unfortunately displays the following:

enter image description here

This can obviously be changed by formatting the excel column to number, text etc.. however when saved as a CSV format it becomes impossible to change as every time you close the document it reverts back to it's original state.

When viewing the CSV file in Notepad++, the barcode will show fine although when I import the file into PHPMyAdmin, the barcode will show in the same way as the CSV.

So my question splits into two parts:

  1. What is the best format to import my spreadsheet on?
  2. How do I resolve this annoying format.
  • 写回答

1条回答 默认 最新

  • dongrong5189 2013-12-14 03:43
    关注

    I'd say your data in the spreadsheet is stored incorrectly; it should be treated as text rather than a number. Likewise in the database. That will handle your question #2 and prevent this from becoming a problem in your database. It's not really a numeric representation (for instance a count of anything); it's a string of identifying characters that all happen to be digits. That seems to me like it should be represented as a string column type such as CHAR or VARCHAR.

    I believe you said that the CSV looks fine (as in 5028252188661), so if you set the MySQL table to expect a string rather than a numeric type you should see the correct value represented after you import as well.

    评论

报告相同问题?

悬赏问题

  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?