[英]How do I preserve the leading 0 of a number using Unoconv when converting from a .csv file to a .xls file?
I have a 3 column csv file.我有一个 3 列 csv 文件。 The 2nd column contains numbers with a leading zero.第二列包含带前导零的数字。 For example:例如:
044934343 044934343
I need to convert a .csv file into a .xls and to do that I'm using the command line tool called 'unoconv'.我需要将 .csv 文件转换为 .xls 并为此使用名为“unoconv”的命令行工具。
It's converting as expected, however when I load up the .xls in Excel instead of showing '04493434', the cell shows '4493434' (the leading 0 has been removed).它按预期转换,但是当我在 Excel 中加载 .xls 而不是显示“04493434”时,单元格显示“4493434”(前导 0 已被删除)。
I have tried surrounding the number in the .csv file with a single quote and a double quote however the leading 0 is still removed after conversion.我曾尝试用单引号和双引号将 .csv 文件中的数字括起来,但转换后仍会删除前导 0。
Is there a way to tell unoconv that a particular column should be of a TEXT type?有没有办法告诉 unoconv 特定列应该是 TEXT 类型? I've tried to read the man page of unocov however the options are little confusing.我试图阅读 unocov 的手册页,但是这些选项有点令人困惑。
Any help would be greatly appreciated.任何帮助将不胜感激。
Perhaps I came too late at the scene, but just in case someone is looking for an answer for a similar question this is how to do:也许我在现场来得太晚了,但以防万一有人正在寻找类似问题的答案,这是如何做的:
unoconv -i FilterOptions=44,34,76,1,1/1/2/2/3/1 --format xls <csvFileName>
The key here is "1/1/2/2/3/1" part, which tells unoconv that the second column's type should be "TEXT", leaving the first and third as "Standard".这里的关键是“1/1/2/2/3/1”部分,它告诉unoconv第二列的类型应该是“TEXT”,第一列和第三列是“标准”。
You can find more info here: https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options#Token_7.2C_csv_import您可以在此处找到更多信息: https : //wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options#Token_7.2C_csv_import
BTW this is my first post here...顺便说一句,这是我在这里的第一篇文章......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.