Write the first lines of multiple csv files to Excel
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 |
Write the following code in SPL IDE:
=T("result.xlsx": directory@p("D:\\data\\*.csv").(T(~)(1)))
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.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_Desktop/
SPL Learning Material 👉 https://c.scudata.com
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProcDesktop
Linkedin Group 👉 https://www.linkedin.com/groups/14419406/