Write Space-separated Text Files to an Excel File
【Question】
I am trying to read data from text files (which is an output given by Tesseract OCR) and save it in an Excel file. The problem I am facing here is that the text files are in space-separated format, and there are multiple of them. Now I need to read all the files and save them in Excel sheets. 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 Excel-write the same. But I haven’t found a good solution. Any guidance would be of great help.
【Answer】
It’s easier to handle this in SPL (Structured Process Language) than in MATLAB:
A |
|
1 |
=directory@p("D:\\files\\*.txt") |
2 |
=A1.(file(~).import(;," ")) |
3 |
=A2.(file("D:\\" /#/ ".xlsx").xlsexport (~)) |
A1: List all text files under D:\\files\\ directory;
A2: Import data from these text files;
A3: Export data of them to an xlsx file.
The text files can be stored in different directories. A text file can be exported to a namesake xlsx file. You can call the above SPL script at command line or integrate it with another application.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL