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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
zalibra
Contributor III
Contributor III

Append file value to filename

Should be a simple task but does not seem to work. 

 

I've created a file called Batch_ID.csv (can be .json, .xls, etc.) which has just one value -- a sequential ID I generate after every job -- and saved in my folder Users/zalibra/Desktop/S3Test. So, today's Batch_ID will have value 1, tomorrow's Batch_ID will have 2, day after tomorrow 3, etc. Each day, before I run the new batch, I delete the old files. So at any one point, there will be only one Batch_ID file in my folder.

 

I now want to create a new file pulling data from a website. The filename of this new file should take the value from Batch_ID.csv and append to it. I put

"/Users/zalibra/Desktop/S3Test/" +(String)globalMap.get("/Users/zalibra/Desktop/S3Test/Batch_ID.csv") + "-" + TalendDate.getDate("CCYYMMDD") + "-Exchange.json"

in the File Name in tFileOutputJSON_1 but the filename is not using the Batch_ID value. tFileOutputJSON file is getting created with filename "null-<today's data>-Exchange.json" 

 

I know I'm messing up in "+(String)globalMap.get("/Users/zalibra/Desktop/S3Test/Batch_ID.csv") +"; does anyone have the right command?0683p000009M2qh.jpg

Labels (3)
1 Solution

Accepted Solutions
zalibra
Contributor III
Contributor III
Author

Below is what was done to resolve this. 

 

tDBInput --> tFileOutputDelimited (containing the sequence # generated by calling the Postgresql function)

tFileInputDelimited --> tJavaRow --> tLogRow (to pick up the ID from the tFileOutputDelimited above to then append to the filename in tFileOutputJSON below)

tFileInputJSON --> tFileOutputJSON (tFileOutputJSON gets the raw JSON data from the stock exchange as the content of the file and then uses the sequence # from tFIleInputDelimited to append to the filename)

 

tJavaRow: 

System.out.println("context = "+ row6);
context.setProperty("sequence", row6.id);

0683p000009M2us.jpg

View solution in original post

5 Replies
manodwhb
Champion II
Champion II

@zalibra ,can you try with below one instead of (String)globalMap.get("/Users/zalibra/Desktop/S3Test/Batch_ID.csv") and let me know.

 

((String)globalMap.get("tFileOutputDelimited_1_FILE_NAME"))

zalibra
Contributor III
Contributor III
Author

No luck, still the same -- "null-<today's date>-Exchange.json". Not sure what I'm missing; it can't be this difficult. 

 

I have an existing file with value "1" in my folder - /Users/zalibra/Desktop/S3Test/Batch_ID.csv. I just want to use that value to create a new file called "1-<today's date>-Exchange.json". Everything works except for the "1". 

manodwhb
Champion II
Champion II

@zalibra ,read that file and load to  context and use that context value  in the file name.

 

 

 

"/Users/zalibra/Desktop/S3Test/" +context.batchid + "-" + TalendDate.getDate("CCYYMMDD") + "-Exchange.json"
zalibra
Contributor III
Contributor III
Author

Came across this on another thead which is why, I think, giving a File Name directly to my Exchange file won't work -- the content of the Exchange file will have data pulled directly from a stock exchange but the filename of the Exchange file will use a value from an already-created file in a folder. So, essentially, I'm joining data from two different sources to create my Exchange file. 

 

"Interesting to know that the tOputputFileDelimited gets created at the start of the process. Just put it into two separate queries
1. gets the file name and assigns it to the context variable
2. gets the content of the file and inserts it into the outputDelimited (calling the context variable which was set in step 1).

 

https://community.talend.com/t5/Archive/resolved-Assigning-value-to-context-and-context-to-filename/..."

zalibra
Contributor III
Contributor III
Author

Below is what was done to resolve this. 

 

tDBInput --> tFileOutputDelimited (containing the sequence # generated by calling the Postgresql function)

tFileInputDelimited --> tJavaRow --> tLogRow (to pick up the ID from the tFileOutputDelimited above to then append to the filename in tFileOutputJSON below)

tFileInputJSON --> tFileOutputJSON (tFileOutputJSON gets the raw JSON data from the stock exchange as the content of the file and then uses the sequence # from tFIleInputDelimited to append to the filename)

 

tJavaRow: 

System.out.println("context = "+ row6);
context.setProperty("sequence", row6.id);

0683p000009M2us.jpg