一批空格分隔的文本转成 xlsx

【问题】

I am trying to read data from text file (which is output given by Tesseract OCR) and save the same in excel file. The problem i am facing here is the text files are in space separated format, and there are multiple files. Now i need to read all the files and save the same in excel sheet. I am using MATLAB to import and export data. I even thought of using python to convert the files into CSV format so that i can easily import the same in MATLAB and simply excelwrite the same. But no good solution. Any guidance would be of great help.

thank you

【回答】

这个问题用SPL处理要比MATLAB简单些:


A

1

=directory@p("D:\\files\\*.txt")

2

=A1.(file(~).import(;," "))

3

=A2.(file("D:\\" /#/   ".xlsx").xlsexport (~))

 

A1:列出目录D:\\files\\下的所有文本文件。

A2:读取这些文本文件的内容。

A3:将文本文件内容分别写到xlsx

也可以指定不同目录下的文件,或以同名文件输出到xls,可命令行调用或集成使用。