file reader starting point in different rows

Hi,

 

I´m new here, but I used the informations of this forum very often to learn Knime. Great Information base!

My actual problem is within a loop if csv-files. Unfortunately the header of the files hasn´t always the same number of rows, so I can´t use the fnction to skip a fix number of rows. I have a character two lines above the header row to identify the starting point.

 

Is there any solution to use this information to "standardize" the csv´s? I even thought about a way to delete rows until this point to get a clean database for the loop.

Reading all the rows, and then using a Row Filter node to remove those that match your header pattern might work.

 

Steve

Thanks for the reply.

 

Unfortunately not all Rows I want to delete have this pattern. It´s just one above the needed data.

 

I´m searching for a node to remove rows until the pattern is found.

OK, try this in a Java snippe row filter node, put the following code in the top box ('Global Variable Declaration' - stuff in here is persisted between rows in the incoming table):

boolean commentFound=false;

And then in the 'Method Body' part put:

//Replace with your pattern
String pattern="#";
if($column1$.startsWith(pattern)){
	//We've found the pattern,
	//But still dont want this/ese line(s)
	commentFound=true;
	return false;
}

if(!commentFound){
	//We've not yet found the pattern
	return false;
}

//To get here, we must have found the pattern
//And not be starting with the pattern;
return true;

/*
 * NB For simplicity, the above from
 * 'if(!commentFound)... could be replaced
 * with return !commentFound;
 */

This should give you what you want. You will need to replace

$column1$

with the relevant column (highlight this text, and then double click on the column name you want in 'Column List' part of the configuration dialog), and pattern with whatever comment pattern your line starts with.  I tried this on the following dummy input:

Column 1
Some stuff not needed
more not needed
#Comment before data
My first data line
My next data line
 

And got the following out:

		<table>
			<tbody>
				<tr>
					<td>Column 1</td>
				</tr>
				<tr>
					<td>Some stuff not needed</td>
				</tr>
				<tr>
					<td>more not needed</td>
				</tr>
			</tbody>
		</table>

		<p>&nbsp;</p>

		<p>Does that help do what you want?</p>

		<p>Steve</p>

		<p>&nbsp;</p>

		<p>&nbsp;</p>
		</td>
	</tr>
</tbody>

Thanks a lot. Works for me, even If I´m absolute stupid regarding Java. Great support!

No problem! When I first started using KNIME I knew no Java either!

Steve