Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III

Header and trailer validation of csv file

Hi,
I have .csv file having multiple colmns,i need to do hader and trailer validation on csv file.
first row of csv file consisting name of column ,which should go in header file.and
last row of csv file consist total count of rows(eg.100) in file ,the count shoud goes in trailer file,
so how to do that header and trailer validation.
layout of csv file
col1 | col2 | col 3 | ...|.... } :this row goes to in header.csv file
data1 | data2 | data3 |..........
.
. :this rows(total 90 rows) goes to in maindata.csv file
.
90 :this count should goes to trailer.csv file

So will you please suggest that ,how to achive this?
Labels (3)
5 Replies
Anonymous
Not applicable

Hi,
For your requirement, you can control the num of "header" and "footer" on tFileInputDelimited.
To make it clear, I have designed a demo job.
The input file:
id,name,sex
1,shong,m
2'sabrina,f
3,Elise,f
The expected result is:
outfile 1
1,shong,m
outfile2
3,Elise,f
Please see my screenshots for details
Best regards
Sabrina
0683p000009MDMz.png 0683p000009MDN4.png
_AnonymousUser
Specialist III
Author

Hi,
Many thanks for your quick reply. Actually my requirement is a little bit different.
The file will be something like -
Name Age Mobile This is the Header in my case. Meaning we do not have any value for Header.
abc 22 97453
hkh 33 86541
hfk 16 90686
lmn 19 56312
4 The data 4 is the count of no of recrods we have which is just an example and may vary
And so this is the trailer.

We want to validate that count mentioned in trailer ie 4 in our example case and the actual num of records present in the file ie 4 in our case matches or not.
So it is something like to first take the last record of the file into 1 file and store the value. Then do a count of the remaining records to get a count of 4 and then do a match.
Please let me know if you got it.
Thanks
bkar81
Contributor III

Check out the screenshots below
Edit: Instead of tLogRow, place a tFileOutputDelimited component.
If the footer has more than 1 row, then in the tJava row (say for example 3 rows), you can specify
String footer_rows = ((Integer)globalMap.get("tFileRowCount_1_COUNT")-2)+".."+(Integer)globalMap.get("tFileRowCount_1_COUNT");
0683p000009MDHs.png 0683p000009MDN9.png 0683p000009MDNE.png 0683p000009MDKk.png 0683p000009MD4E.png 0683p000009MDNJ.png 0683p000009MDNO.png
Anonymous
Not applicable

Hi,

 

I am generating a .csv file using tFileOutputDelimited component. 

My requirement is to append a footer while generating the file. (In my generated csv file i need extra row at the end).

 

Please suggest.

Anonymous
Not applicable

Hello @MNK_2019 

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina