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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
anyxs
Contributor II
Contributor II

One CSV file to multiple output files by column value – tFlowToIterate creates empty files

Hi,

I have a single CSV file with the following structure:

id_soc;code_soc;date;lieu;nb_clients
01;nj0120;120225;paris;25
02;nj0120;160523;nantes;10
03;jf2563;250426;leHavre;5

I want to split this CSV into multiple output CSV files, one per code_soc, with the following format (example for nj0120😞

code_soc;date;lieu;nb_clients
nj0120;120225;paris;25
nj0120;160523;nantes;10

I tried using a tFlowToIterate to loop over each code_soc and generate a file with a dynamic name like:

"fichier_" + code_soc + ".csv"

The files are created with the correct names, but they are empty.

What is the best way to split one CSV into multiple CSV files dynamically based on a column value, without having to manually create a filter for each value?

Thanks in advance!

Labels (2)
1 Solution

Accepted Solutions
anyxs
Contributor II
Contributor II
Author

This solution   worked for me ! 
Thanks 

View solution in original post

4 Replies
Rahul_Kale
Support
Support

Hello anyxs,
 

Thank you for reaching out to the Qlik community.
 

Best approach: use “Dynamic filename” in tFileOutputDelimited — no iterate needed.


Instead of tFlowToIterate, use tFileOutputDelimited with “Use dynamic filename” (or Expression in File Name) directly in the flow.
 

Steps

  1. tFileInputDelimited → read your CSV
  2. (Optional) tMap → remove id_soc
  3. tFileOutputDelimited
    • ✔ Check “Append” = true
    • ✔ Use “File name/Stream (expression)”
    • Set: "output/fichier_" + row1.code_soc + ".csv"
  • ✔ Check “Include Header”
  • ✔ Enable “Write header only once”

This will automatically:

  • create one file per code_soc
  • group rows correctly
  • avoid empty files

 

tFlowToIterate is not meant for row-by-row file writing — it passes values via globalMap, and you lose row streaming → leads to empty outputs, and that is the reason why your method failed.

 

anyxs
Contributor II
Contributor II
Author

Hi Rahul,

Thank you for your answer,

So I tried :
- Left "Use output stream" UNCHECKED
- In the standard "File name" field, typed the String path: "C:/export/fichier_" + out1.code_soc + ".csv"
- Checked "Append"
- Checked "Include header"

But this does not work either — I get a fichier_null.csv in the right path with all the data from the source csv

My current flow is:
tFileInputDelimited → tMap (remove id_soc) → tFileOutputDelimited

Is there a specific update for the tFileOutputDelimited or another solution ?

Thanks

anyxs
Contributor II
Contributor II
Author

This solution   worked for me ! 
Thanks 

Rahul_Kale
Support
Support

Hello anyxs,
 

You have marked the wrong comment as an accepted solution; the information that worked for you, you will need to mark as an accepted solution.