简体   繁体   English

保留 kronos 导出的前导零

[英]Keep leading zeros from a kronos export

I am exporting some data on a flat file from an application to a sharefile into a .csv file.我正在将平面文件上的一些数据从应用程序导出到共享文件中,然后将其导出到.csv文件中。 The leading zeros get dropped after the export.导出后前导零被删除。 I'am trying to find a way to keep the leading zeros after on the .csv file after the export.我试图找到一种方法来在导出后保留.csv文件的前导零。

在此处输入图片说明

File that is export from the source with kronos使用 kronos 从源导出的文件

在此处输入图片说明

Result of the export in a sharefile on .csv with the missing leading zeros..csv上的共享文件中导出的结果,其中缺少前导零。

Excel interprets the values as numbers and will remove leading zeroes. Excel 将这些值解释为数字并将删除前导零。 If you want to keep the leading zeroes in Excel, the data needs to be text in double quotes.如果要保留 Excel 中的前导零,则数据需要是双引号中的文本。

As teylyn answered, the dropping of leading zeros is just Excel interpreting the values as numbers.正如 teylyn 回答的那样,去掉前导零只是 Excel 将值解释为数字。 you should be able to verify this by opening the file in Notepad etc, the full ID's should appear.您应该能够通过在记事本等中打开文件来验证这一点,应该会出现完整的 ID。

Depending on what you're using the the csv data in Excel for, there's couple of workarounds, assuming you can't change the output format to wrap the ID's in double quotes.根据您在 Excel 中使用 csv 数据的目的,有几种解决方法,假设您无法更改输出格式以将 ID 括在双引号中。

If you're just using Excel to view/verify the data then there's no problem, just don't save it when you close the file in Excel.如果您只是使用 Excel 查看/验证数据,那么没有问题,只需在 Excel 中关闭文件时不要保存它。

If you're doing other things in the csv file and then saving it as an xlsx file, then you can use a formula to 'fix' the ID's.如果您在 csv 文件中执行其他操作,然后将其另存为 xlsx 文件,则可以使用公式来“修复”ID。 In say E2 put =REPT("0",6-LEN(A2))&A2 which will in effect pad out the ID's to 6 characters long with leading zeros.在说 E2 中放置=REPT("0",6-LEN(A2))&A2这实际上将用前导零填充 ID 到 6 个字符长。 You can then copy/paste the values into column A and delete column E then save.然后,您可以将值复制/粘贴到 A 列并删除 E 列,然后保存。

If you're playing around with the data in Excel then Power Query is probably a better bet than adding formulas/replacing values etc.如果您在 Excel 中处理数据,那么 Power Query 可能比添加公式/替换值等更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM