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

前端 未结 2 1119
礼貌的吻别
礼貌的吻别 2021-01-20 13:37

In R i have a script gets content of multiple xls files .

All files are about 2 MB. The script takes a few seconds for 3

相关标签:
2条回答
  • 2021-01-20 14:11

    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.

    0 讨论(0)
  • 2021-01-20 14:34

    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" 
    
    0 讨论(0)
提交回复
热议问题