FileReader question

Hi,

I would like to get only the comment lines from a given file. Actually I need both but in two separate outputs...

One way would be to read in everything and use RowFilter. This has the disadvantage that some columns are not assigned correctly to integer values. Changing this with JavaSnipets is very expensive.

The second way I can think of is to read the file twice. this is OK for reading in the data, but when I set the single line comment to the first character of the data files somehow the interface hangs...

The third way would be to read in only the first e.g. 1000 lines and the use the row filter in order get the header lines...

All is not very convincing....

The next way would be to write a new node based on the FileReader node that output as a second output the header lines.... This would be probably the perfect solution. But after looking through the code for some time I couldn't find a way to realize this...

Could you please comment, maybe point me to the position on how I could create a new fileReader?

 

Thanks a lot

B

Hi baj!

In order to create your own file reader you could use the FileReaderNodeSettings, FileAnaylzer and FileTable. The ExtToolNodeModel has an example how to use them (method readOutputFile). This ExtTool Node reads the file without user interaction and reads what ever comes.

If you need to have more control, you either can set more details in the FileReaderNodeSettings or use the Tokenizer class (that reads String tokens from the file).

The ARFF Reader might also be a good class to look at, because it needs to juggle with tokenizer settings, too (class ARFFTable).

 

I hope these are helpful pointers, let me know if you need more details.

 - Peter.

P.S.: Can you reproduce the interface freeze? Could you describe the steps to freeze it?

P.P.S.: The ColumnRenamer can (despite its name) also change the type of the columns.