How can I prevent leading zeroes from being stripped from columns in my CSV?

冷暖自知 提交于 2020-01-07 02:37:23

问题


I need to upload a CSV file, but my text data 080108 keeps converting to a number 80108. What do I do?


回答1:


Use Quoted CSV

Use quotes in your CSV so that the column is treated as a string instead of an integer. For example:

"Foo","080108","Bar"



回答2:


I have seen this often when viewing the CSV using Microsoft Excel. Excel will truncate leading zeros in all number fields. if the output is not coming from excel then check the output in note pad. If it is coming from excel you need to add a single quote mark ' to the beginning of each zip code. then excel will retain the leading 0.



来源:https://stackoverflow.com/questions/14074305/how-can-i-prevent-leading-zeroes-from-being-stripped-from-columns-in-my-csv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!