bash 如何在 unix 中将 xlsx 转换为 csv
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42826845/
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
how to convert xlsx to csv in unix
提问by Midhun
I have a text file (abc.txt
) which will be having the file name along with the path which is to be converted to .csv
.
我有一个文本文件 ( abc.txt
),它将包含文件名以及要转换为.csv
.
I am getting error saying that
我收到错误说
Selected exporter does not support saving multiple sheets in one file.
选定的导出器不支持在一个文件中保存多个工作表。
Only the current sheet will be saved. But it not getting saved for one tab as well.
只会保存当前工作表。但它也没有为一个标签保存。
Below is the query that I have wrote
下面是我写的查询
#!/bin/bash
CURRENT_DATE=date +'%d%m%Y'
Temp_Path=/my/first/path
cd $Temp_Path
#rm INBOUND_XLSX_FILES_.txt
find /my/second/path -name ".xlsx" >> "$Temp_Path/conversion.txt"
while IFS= read -r "f" ; do
filename="${f%.*}"
ssconvert "${filename}".xls
"${filename}".csv
done < conversion.txt
回答by Socowi
For a .xlsx with multiple sheets, you have to export each sheet as a separate .csv file. Of course different files must have different names.
对于包含多张工作表的 .xlsx,您必须将每张工作表导出为单独的 .csv 文件。当然不同的文件必须有不同的名称。
You could either name the sheets by a number, using %n
您可以通过数字命名工作表,使用 %n
ssconvert --export-file-per-sheet "$filename.xlsx" "$filename-%n.csv"
or name the sheets by their names, using %s
或按名称命名工作表,使用 %s
ssconvert --export-file-per-sheet "$filename.xlsx" "$filename-%s.csv"
Instead of --export-file-per-sheet
you can also use the shorthand notation -S
with exactly the same effect.
--export-file-per-sheet
您也可以使用-S
具有完全相同效果的速记符号来代替。