How to Store Specified CSV Columns to a New File
Problem description & analysis
Below is data in CSV file csv.csv:
upc14 column is the logically unique index by which data should be ordered. Get this column and name column to store them as a text file as follows:
Solution:
We write the following script p1.dfx in esProc:
A |
|
1 |
=file("csv.csv").import@tc(upc14:string,name) |
2 |
=A1.sort(upc14) |
3 |
=file("result.txt").export@t(A2) |
Code description:
A1 Read string type upc14 column and name column from the CSV file.
A2 Sort A1’s data by upc14 column.
A3 Export A2’s result to result.txt.
See How to Call an SPL Script in Java to learn about the way of integrating the SPL code with a Java program.
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