bash 使用带分隔符的“ssconvert”将 CSV 转换为 XLS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28895383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 12:29:28  来源:igfitidea点击:

Convert CSV to XLS using 'ssconvert' with delimiter

bashexport-to-excelconvertersimport-from-csvssconvert

提问by Patrick

I've got a CSV file with delimiter character being |, but can't really find a way to convert it to XLS that would apply the delimiter.

我有一个带有分隔符的 CSV 文件|,但无法真正找到将其转换为适用分隔符的 XLS 的方法。

ssconvert -O 'separator=|' test.csv test.xls

will obviously yield with message like:

显然会产生如下消息:

The file saver does not take options

文件保护程序没有选项

The outcome is an XLS file with entire rows treated as one column (concatenated, like in text format) instead of spread according to given delimiter. Expected outcome is obviously properly delimited file.

结果是一个 XLS 文件,将整行视为一列(连接,如文本格式),而不是根据给定的分隔符展开。预期的结果显然是正确分隔的文件。

It's been bothering me for a while, could anybody give me a hint?

困扰我好久了,有大神指点一下吗?

回答by Armali

Unfortunately, option parameters can only be specified for the exporter, not the importer.

不幸的是,选项参数只能为导出器指定,而不能为导入器指定。

But you can replace the delimiter characters |with TABs, so that ssconvertrecognizes columns.

但是您可以用制表符替换分隔符|,以便ssconvert识别列。

tr '|' '\t' <test.csv | ssconvert fd://0 test.xls

回答by superkoning

Does

ssconvert -O 'separator=|' test.TXT test.xls

work for you? So: .TXT, not .CSV

为你工作?所以:.TXT,而不是.CSV