cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle CSV file with header only

amit_saroha
New Contributor III

Hi,
I have CSV files coming through some third parties and sometimes it comes to empty i.e. only with headers and no data. Can you suggest how I can handle such files?

1 ACCEPTED SOLUTION

That is because your file contains an extension .csv but you saved it as .txt

image

image

image
So after saving it as csv it goes to the no data output

Let me know if it works

View solution in original post

9 REPLIES 9

JensDeveloper
Contributor II

Hi @amit.saroha ,

You mean you want those files out? Then I can suggest you check the checkbox ‘ignore empty stream’.
Because it will write those files to the error view (both an empty binary stream and a binary stream with CSV headers only).

You can find the explanation also in the documentation here.

Regards

Jens

I don’t want to error out the pipeline actually.

It doesn’t go out of the pipeline if you don’t want to.

Example below: the csv parser his error data is set to ‘route error data to error view’. Then a error output will be showed above the parser after that you can define what to do with the error map the right fields and sent an e-mail for example.

image

If this solution doesn’t help you there is an option 2:

  • Put a router snap after the csv parser and check if one field of the headers does contain data or not and then route it to an output.

Option 3:
If you don’t want those empty files use a filter snap with a condition that a field is not null and then you only get the filled snaps.

Regards

Jens

amit_saroha
New Contributor III

@JensDeveloper - Thank you, but if I do as you suggested it will create an issue with the insert statement, right? How I can pass “S” in the last mapper in both cases when I have data inserted or not inserted.

image