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

Adding File Header & Trailer

Hi Guys,
I am picking some data from an input csv & generating an output csv file.Now i want the desired output as
File Header (FH): TEST, <sysdate>, <outputfilename>
Header Line (HL): Contains the column header text
Detail Line (DL): Values of fields mentioned in Header line
File Trailer (FT): Contains the- Total Records in the output file generated
I am able to generate the Header Line & Detail line via parsing the csv from tfileinputdelimited & generating file in tfileoutputdelimited.
How to add the File Header & File Trailer in the same file.Please help as i am badly stuck.
Thanks,
Neeraj
Labels (2)
1 Reply
Anonymous
Not applicable
Author

Hi Neeraj,
One way of achieving this is to have three sub jobs.
The first sub job uses a Java flex component (tJavaFlex_1) to write the file header and header line to the output file (tFileOutputDelimited_1). The schema for row1 is a single field by the name LINE (String data type). This job writes both the file header and header line (field names) to the output file.
The second sub job reads the Input file delimited component (tFileInputDelimited_1) and appends the records to the output file (tFileOutputDelimited_2) generated by the first sub job. The "Append" option in" Basic Settings" is enabled for the tFileOutputDelimited_2 component.
The third sub job reads the global variable tFileOutputDelimited_2.NB_LINE to get the number of lines written to the output file (tFileOutputDelimited_2). This is then appended to the output file (tFileOutputDelimited_3). The schema for row3 is a single field by the name RECORD_COUNT (Integer data type). The "Append" option in" Basic Settings" is enabled for the tFileOutputDelimited_3 component.
Since all the sub jobs are should be writing to the same file we need to use the "File Name" for tFileOutputDelimited_1, tFileOutputDelimited_2 and tFileOutputDelimited_3.
Regards,
Abhi