Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Split a file

Hi!

I have a delimited flat file of 1000 lines, I want to divide it into 3 files, depending on the value of column 0, how do I do this? If the value of column 0 is == 1, go to a file; if the value is == 2 it goes to another file.

Thanks!

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

 

    It seems your Column0 is having null values. Could you please modify the code as below to handle the null scenario?

 

Relational.ISNULL(row1.Column0)? null : ((row1.Column0==1) ? row1.Column0 : null)

Warm Regards,
Nikhil Thampi

Please appreciate our members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

11 Replies
TRF
Champion II
Champion II

First solution, 1 tMap with 3 output flow and the appropriate filter expression for each.

Second solution, 1 tFilterRow to separate records for file 1, then a second one to separate records for file 2 and 3.

Anonymous
Not applicable
Author

something I forgot to mention is that those that are type 1 and type 3 have fewer fields than type 2, does this affect?

Anonymous
Not applicable
Author

0683p000009M1aO.png

when I execute it, a Null Pointer error is generated

 

 

Anonymous
Not applicable
Author

Hi,

 

    It seems your Column0 is having null values. Could you please modify the code as below to handle the null scenario?

 

Relational.ISNULL(row1.Column0)? null : ((row1.Column0==1) ? row1.Column0 : null)

Warm Regards,
Nikhil Thampi

Please appreciate our members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

 

I already managed to write different files, but now I want those who do not fulfill the condition, NOT to occupy unnecessary lines.
Thanks!

 

Anonymous
Not applicable
Author

Hi,

 

    The tmap says that your Column0 is not nullable. I hope you have checked the input data is not having any null value for Column0. Also I hope you are not picking any null rows.

 

    If you have checked both these conditions, then you will have to check the functions. Somewhere you are passing the value as  null.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

I already managed to write different files, but now I want those who do not fulfill the condition, NOT to occupy unnecessary lines.
Thanks!

0683p000009M1nW.png

Anonymous
Not applicable
Author

Hi,

 

     Either you can add an null check expression in your output area so that it will not write the empty data. Or you can avoid them by filtering later using a tfilterrow component.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

I already managed to write different files, but now I want those who do not fulfill the condition, NOT to occupy unnecessary lines.
Thanks!