read required columns in a csvfile

22 views
Skip to first unread message

Zubear aj

unread,
Mar 11, 2019, 6:38:26 AM3/11/19
to Scriptella ETL
Hi,
is it possible to select only selected(few) columns instead of all while reading a csv file.
i am reading the data from csv and writing it to a different csv file. i do not wish to use a DB here.

ex:
select empid, empname, salary from  inputcsvfile

Thanks!
Zubear

Christian MICHON

unread,
Mar 11, 2019, 9:00:17 AM3/11/19
to Scriptella ETL
Hi,

all the columns of the input file will be read, 1 row at the time. You can select only those you want to write into another csv file easily.

As an example below, a scriptella xml reading in.csv (https://raw.githubusercontent.com/scriptella/scriptella-etl/master/samples/csv/bugs-in.csv, this file contains 4 columns) and keeping only 2 columns in the destination file out.csv.

Please note the initial <script> is used to create the header of the out.csv.

<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
  <connection id="in" driver="csv" url="in.csv"/>
  <connection id="out" driver="csv" url="out.csv"/>
  <script connection-id="out">
    summary,status
  </script>
  <query connection-id="in">
    <script connection-id="out">
      $summary,$status
    </script>
  </query>
</etl>

Best of luck.
Christian
Reply all
Reply to author
Forward
0 new messages