Icon

kn_​forum_​2734_​aloe_​import_​txt_​file

aloe - import complex TXT file

Ok, I've put together a crude example of a way to do this.

It is dependant on you having a constant number of results though. In this example 8 data row and a blank row (the blank row can be missing at the end of the file though.

You will need to change the red sections to the values in your actual data (96 time rows plus the 5 data rows at the start)

I've also included the text file I used.

Regards
Sam

Double-click to edit. Read in using the line reader. And thechunk loop should be set to thenumber of rows per element (includingthe blank line that seperates the blocks) Remove the blank line andreset the ID We create a dictionary of headers forthe first 5 elements (date, fruit,furniture, color and time) Here we make the column header for the time elements. Then resetthe time value to be the component after the # Join the time data back in, set the column headers to bethe row ID then transpose Collect all the results. Original workflow by swebbhttps://forum.knime.com/t/converting-a-raw-text-file-into-a-data-table/2734/9?u=mlauber71Read fileknime://knime.workflow/data/exampletext.txtnumber ofrows perentryremove 9th elementcolumn headerdictionaryNode 7resetseperate on#replacevaluekeepfirst 5columnsjoin backrename toheaderremoveunwantedset columnto be the headertransposecollect results Line Reader(deprecated) Chunk Loop Start Row Filter Table Creator RowID RowID Joiner (deprecated) Cell Splitter(deprecated) String Manipulation Row Splitter Concatenate Column Rename Column Filter RowID Transpose Loop End(deprecated) Double-click to edit. Read in using the line reader. And thechunk loop should be set to thenumber of rows per element (includingthe blank line that seperates the blocks) Remove the blank line andreset the ID We create a dictionary of headers forthe first 5 elements (date, fruit,furniture, color and time) Here we make the column header for the time elements. Then resetthe time value to be the component after the # Join the time data back in, set the column headers to bethe row ID then transpose Collect all the results. Original workflow by swebbhttps://forum.knime.com/t/converting-a-raw-text-file-into-a-data-table/2734/9?u=mlauber71Read fileknime://knime.workflow/data/exampletext.txtnumber ofrows perentryremove 9th elementcolumn headerdictionaryNode 7resetseperate on#replacevaluekeepfirst 5columnsjoin backrename toheaderremoveunwantedset columnto be the headertransposecollect results Line Reader(deprecated) Chunk Loop Start Row Filter Table Creator RowID RowID Joiner (deprecated) Cell Splitter(deprecated) String Manipulation Row Splitter Concatenate Column Rename Column Filter RowID Transpose Loop End(deprecated)

Nodes

Extensions

Links