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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
zLucy
Contributor
Contributor

[resolved] How to Iterate throw on an hashmap or arrayList and write the result in a csv file in talend open studio

Hi,

I would like to iterate a hashMap or an arrayList in talent open studio, and, for each iteration, I would like to write a new csv row! I've done many tests but the result I get is the override of the first line. Below i post an example.

 

 

The tSetGlobalVar_1component creates the arrayList.

0695b00000nSnbcAAC.png 

 

 

The tJvava_1 component inserts values to arrayList.

0695b00000nSnbwAAC.png 

 

The tLoop_1 component loop to arrayList from 1 to arrayList.size

0695b00000nSnc1AAC.png 

 

The tJavaFlex_1 component get the ArrayList from globalMap and iterare throw it and for each iteration, write the the row to cor column in row1

0695b00000nSncBAAS.png 

 

The tFileOutputDelimeted_1 has one column "code".

0695b00000nSncLAAS.png 

 

 

The output csv file, in the end, has only one row with last value of arrayList.

Could someone help me?

Thanks!!!

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Check the 'Append' box on tFileOutputDelimited to append rows to an existing file.

 

View solution in original post

7 Replies
Anonymous
Not applicable

Hi

You need to set a dynamic output file name on tFileOutputDelimited, eg:

"D:/file/"+(String)myList.get(((Integer)globalMap.get("tLoop_1_current_iteration"))-1)+"out.csv"

otherwise, the component always create a new file with the same name for each iteration.

 

Hope it helps you.

 

Regards

Shong

 

 

zLucy
Contributor
Contributor
Author

Hi @Shicong Hong​ and thanks for yours reply, i don't want to generate more files, i would to generate one csv file with more rows at the same column.

Anonymous
Not applicable

Check the 'Append' box on tFileOutputDelimited to append rows to an existing file.

 

zLucy
Contributor
Contributor
Author

I have checked the 'Append' box but nothing has changed

Anonymous
Not applicable

For testing, add a tLogRow before tFileOutputDelimited to print the value on the console to see if it has the expected output data.

 

zLucy
Contributor
Contributor
Author

Hi @Shicong Hong​ , i checked the "append box" in base settings of tFileOutputDelimted_1 and now it works!

I selected the wrong checkbox (row_mode in advanced settings), the Italian translation fooled me! A thousand thanks.

Anonymous
Not applicable

Glad to hear that, thanks for your feedback!