cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to write an empty CSV file

mtran21
New Contributor III

I am looking for solution on how to write an empty data with headers csv file. I have a Oracle snap that execute a query then output to a csv file. I still want the csv file to be produced even the query returns zero record.
Here is my pipeline
image

2 REPLIES 2

dmiller
Admin Admin
Admin

See Empty CSV File With Header Row


Diane Miller
Community Manager

mtran21
New Contributor III

I am coming back here to share my simple solution how to write an empty CSV file when there is no data in the stream source (SQL or Oracle)

First, you need to do a COUNT query from your database. Then add a router, if COUNT is not equal zero, then do your thing, if COUNT is zero, then add a file Reader to read your empty CSV file that you put in your file directory, then write the file to your destination

So here is my entire pipeline
image

Then first snap is count
image

Then Router Snap
image

Then File Reader to read my empty CSV file with headers
image

Then finally, write that empty CSV file to destination
image

Hope that helps