exporting csv headers

70 views
Skip to first unread message

Andres Olarte

unread,
Mar 16, 2013, 10:06:17 AM3/16/13
to scrip...@googlegroups.com
I have a very simple etl file that reads a table and exports to CSV.  I'm looking for a way to add the headers to my CSV file so that later I can use this data to import to several other databases.  Looking through the docs, I realized that headers="true" only works for reading, not writing.  How can I export these headers? Ideally, I would query something like this: "SELECT * FROM mytable" and  get all columns with their names, so that I don't have to change the export script as I add new columns (only the import script).  Any ideas how to do this?

Thanks

Matt S

unread,
May 9, 2013, 4:27:23 PM5/9/13
to scrip...@googlegroups.com
It's easy to write out the headers prior to your data, with hard-coded columns names:
    <connection id="out" driver="csv" url="myreport.csv"></connection>
    <script connection-id="out"> <!--Writing header -->
MYCOL1, MYCOL2, MYCOL3
    </script>

But it sounds like you'd like to dynamically get that from the table. I'm not sure if this is so much a Scriptella question as a SQL question. I'm not sure how go query a DB and get column names.
Reply all
Reply to author
Forward
0 new messages