简体   繁体   English

从 .csv 文件转换为 .xls 文件时,如何使用 Unoconv 保留数字的前导 0?

[英]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.

相关问题 使用python脚本将文件从.xls转换为.csv时,如何使数字不显示为指数? - How to get numbers to NOT appear as exponentials when converting a file from .xls to .csv using python script? 将CSV文件转换为XLS时的问题 - Issues in converting CSV file in to XLS 在 scrapy csv 文件中保留前导零 - Preserve leading zeros in scrapy csv file 使用to_csv将Excel文件转换为csv,即使将单元格格式化为字符串,也会删除前导零 - Converting Excel file to csv using to_csv, removes leading zeros even when cells are formatted to be string 在 Python 中将 xls 文件转换为 csv/txt 文件 - Converting xls file into csv/txt file in Python 在VS中从arduino接收字符串,如何将其存储在csv或xls文件中? - Receiving strings from arduino in VS, how do I store them in a csv or xls file? 使用VB.net将.CSV文件转换为.XLS - Converting .CSV file to .XLS using VB.net 你如何使用python在csv文件中保持前导零? - how do you keep leading zeros in a csv file using python? 如何使用 VBA 从 XLS 创建操作过的 CSV 文件 - How to create a manipulated CSV file from XLS using VBA 使用IBM iSeries Client Access从AS400 db文件创建.CSV文件时,我可以挤出前导空白吗? - When using IBM iSeries Client Access to create a .CSV file from an AS400 db file, can I squeeze out leading blanks?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM