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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
una_xikilla
Contributor
Contributor

Split a input file into multiple output files

Hello,

I have an input file and I want to make "n" output files using distinct value.

Eg:

Input File

HZARA 123

L123456HY

L98798676

L54354254

HCUSTO456

L98687687

L64746689

 

I need n different files based on distinct values in Col1 with "H".

 

HZARA.txt

L123456HY

L98798676

L54354254

 

HCUSTO.txt

L98687687

L64746689

 

Any help in this direction would be vey helpful. 0683p000009MPcz.png

Labels (2)
19 Replies
TRF
Champion II
Champion II

Hi,

You cannot use "!=" operator for a string.

Try to import the attached job.


splitFiles.zip
una_xikilla
Contributor
Contributor
Author

Thank you very much!! You are the best! 0683p000009MACn.png

 

I have trying do the same job but i have errors. Could you tell me why please? 0683p000009MPcz.png


Pruebas.zip
TRF
Champion II
Champion II

I cannot import your job (due to the version).
Can you share components configuration for those you are not sure?
una_xikilla
Contributor
Contributor
Author

¡Now work!

I forget to declare the variables in "Contexts"... 0683p000009MAqJ.png

 

Thank you for all (especially for your patience) 0683p000009MAq9.png

TRF
Champion II
Champion II

Great!

You're welcome.

Think to select the answer which help you most and mark the question as solved.

Kudos also accepted 0683p000009MA9p.png

premv258
Contributor
Contributor

If you just want to split the input file based on row count. Then Use  tFileOutputDelimited.

Go to Advanced setting  and tick (Split output in several files) and you can mention number of row you need in each output file.0683p000009Lzlt.jpg

 


asas.JPG
mclee
Contributor III
Contributor III

Hi TRF,

 

I have the similar scenario but only the input is different, where the keywords is after the records. How do I achieve the similar output?

 

Input File

L123456HY

L98798676

L54354254

HZARA 123  <-- the Hxxxx indicator is after the data

L98687687

L64746689

HCUSTO456 <-- the Hxxxx indicator is after the data

 

Output just like una:

HZARA.txt

L123456HY

L98798676

L54354254

 

HCUSTO.txt

L98687687

L64746689


Regards,

MC Lee

TRF
Champion II
Champion II

You should have a look to tMemorizeRows / tJavaFlex to solve your case.

Have a look to the tMemorizeRows documentation which contains an example.

 

billimmer
Creator III
Creator III

Hi TRF,

I ran across your reply while working on a similar problem.  But there is something I don't understand.  Your example works as it should, but if instead of using a subjob for the tFileOutputDelimited, you filter directly to the tFileOutputDelimited, then only one .txt file is generated and the file is named ".txt", as if the context.filename is blank.  

 

What is different about putting the output in a subjob vs. after the filter?

 

Thanks!

TRF
Champion II
Champion II

Because you cannot change the output file from one row to an other, you must break the flow sequence. Another way to do that is to use tFlowToIterate and tIterateToFlow components.