Five Stars

Ignore Header information on CSV

Hello dear

 

I have a csv file that contains dynamique informations on header that we dont know number of line,  and then i have columns like that :

 

line1                                    Country : French;

line2                                    Date : 27/04/2017;

lineN                                   (Can be other informations)

lineN+1                               ID;Product;Size;

lineN+2                               1;TV;32;

lineN+3                               1;Phone;N/A;

 

I want to keep just fields concerned ID,Product and size because i use them on a Tmap

 

 

Regards

 

 

  • Data Integration
1 ACCEPTED SOLUTION

Accepted Solutions
Seven Stars TRF
Seven Stars

Re: Ignore Header information on CSV

Here is my proposal,

Capture.PNG

 

Initialize a boolean global variable:

Capture.PNG

 

Read the file with tFileInputDelimited.

Pass the rows to tJavaRow which to set "headerPassed" to "true" when needed:

Capture.PNG

Filter rows in tMap:

Capture.PNG

Here is the result:

Capture.PNG

 

Regards,

 


TRF
6 REPLIES
Six Stars

Re: Ignore Header information on CSV

Hi,

What is your question here?

Regards,
Veeranjaneyulu Boppudi
Seven Stars TRF
Seven Stars

Re: Ignore Header information on CSV

Here is my proposal,

Capture.PNG

 

Initialize a boolean global variable:

Capture.PNG

 

Read the file with tFileInputDelimited.

Pass the rows to tJavaRow which to set "headerPassed" to "true" when needed:

Capture.PNG

Filter rows in tMap:

Capture.PNG

Here is the result:

Capture.PNG

 

Regards,

 


TRF
Six Stars

Re: Ignore Header information on CSV

Hi,

If you don't know header records count and still need to filter header records and load only valid data into target then try below. Here i assumed ID valid value is numeric.

 

Header.PNG

 

In tMap, used filter condition based on ID is numeric. If it is numeric then pass else reject.

Mathematical.NUM(row1.ID)==1

 

Regards,

 

Veeranjaneyulu Boppudi
Seven Stars TRF
Seven Stars

Re: Ignore Header information on CSV

@vboppudi, Hazardous (IMHO) as you don't know what may arrive before the real header.

The solution I proposed works at any time (any rows number, any content).

 


TRF
Five Stars

Re: Ignore Header information on CSV

    @TRF  I will test your solution, and i return,

Five Stars

Re: Ignore Header information on CSV

@vboppudi ID is alphanumeric