R Linux Shell convert multi-sheet xls to csv in batch

烈酒焚心 提交于 2019-12-01 20:51:36

If you know the worksheet name, you can do this:

for f in *.xls ; xls2csv -x "$f" -w sheetName -c "${f%.xls}.csv";done

To see all the xls2csv details see here.

EDIT

The OP find the right answer, so I edit mine to add it :

for f in *.xls ; do xls2csv -x "$f" -f -n 14 -c "${f%.xls}.csv" 

For this job I use a python script named ssconverter.py (which you can find here, scroll down and download the two attachments, ssconverter.py and ooutils.py), which I call directly from R using system().

It can extract a specific sheet in the workbook, not only by name but also by sheet number, for example:

ssconverter.py infile.xls:2 outfile.csv

to extract the second sheet.

You need to have python and python-uno installed.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!