cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the first line of source CSV and produce last line of output file

Abhijit
New Contributor

The first line of the source CSV has to be converted into the second line of target (also to add a first line manually). Rest of the lines in the target file to produce line-by-line for each source file, after line -2 onward. Hope it make sense, as following:

                                   Target Line 1 (FIXED VALUE - beginning of file marker)

Source Line-3 ---->>>> Target Line 2 (different processing logic - convert data from source line 3)
Source Line-2 (Header of source data) ---->>>> Ignore
Source Line-3 ---->>>> Target Line 3
Source Line-4 ---->>>> Target Line 4
Source Line-5 ---->>>> Target Line 5


------------------- ------ >>>> Target Last Line ( different processing logic - convert data from source line 1 - End of file marker).

TAB separated target file, have one format for line-1, another for line-2, another for last line and anoter format for rest of the middle between Line-3 to last-line.

2 REPLIES 2

itrpkov
Employee
Employee

One mechanism that can be used to isolate separate lines is to use Copy snap after CSV file has been parsed, for example, with 3 (or more) output views. You can then use Filter snaps and snap.in.totalCount function as a filter expression. To get the first line you can specify snap.in.totalCount ==1, for the second line you can specify snap.in.totalCount ==2 etc. Then you can use Union snap to collect the lines back etc. Hope this helps.

Thanks for your reply. I found a working solution allready. I am writing 4 different structure/ lines into 4 different files locally into SnapLogic and then reading/merging them together to produce the desired target file. Thanks for your suggestion though.