#31 — Write The First Lines of Multiples CSV Files to Excel

Judith-Excel-Sharing - Jul 23 - - Dev Community

Problem description & analysis:

There are multiple csv files of same structure in a certain directory:

original csv file

Task: Take the first line of each file (without column headers) and write them to an Excel file.

desired Excel file

Solution:

Write the following code in SPL IDE:

=T("result.xlsx": directory@p("D:\\data\\*.csv").(T(~)(1)))
Enter fullscreen mode Exit fullscreen mode

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.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player