Problem description & analysis:
There are multiple csv files of same structure in a certain directory:
stock_301500.csv | stock_320688.csv |
CODE,DT,OP,CL 301500,2023-06-02,71,67.8 301500,2023-06-05,79.35,72.61 301500,2023-06-06,75.8,77.65 | CODE,DT,OP,CL 320688,2023-06-02,33,32 320688,2023-06-05,28.37,30.23 320688,2023-06-06,27.19,28.54 |
Task: Take the first line of each file (without column headers) and write them to an Excel file.
A | B | C | D | |
1 | CODE | DT | OP | CL |
2 | 301500 | 2023-06-02 | 71 | 67.8 |
3 | 320688 | 2023-06-02 | 33 | 32 |
Solution:
Write the following code in SPL IDE:
=T("result.xlsx": directory@p("D:\\data\\*.csv").(T(~)(1)))
Explanation:
directory@p lists file names with full paths according to the wild character. T()function reads files or writes data to a file as a specified format according to the file extension; ~ is the current member, and (1) represents the first line.
For more references⬇️
SPL download address: esProc Desktop Download
Plugin Installation Method: SPL XLL Installation and Configuration
References to other rich Excel operation cases: Desktop and Excel Data Processing Cases
SPL Programming (YouTube FREE courses): https://www.youtube.com/playlist?list=PLQeR-IhHo7qNCw6o7PW8YfHvRx8pgzZso