Reading specific data from .txt file

Hi, I have several .txt files which represent maximum rainfall for specific months for different durations of the rain. I also have maximums for the specific year and everything is formated in the unfied type of tables. I attached the screenshot. Can someone please suggest how to extract just specific data (year=godina) and a bottom row at the table ( yearly maximums). Best wishes.

Could you please upload an example file?

Sure, find it attached. I open it with Notepad.
station example.txt (334.1 KB)

Hi looks like your rows can be identified by the values in the first column? If so you should be able to use a row filter

Here’s my solution station – KNIME Hub I’ve tried to structure the data a bit. Hope it’s what you needed


Wow, that is perfect! Thanks. Where can I learn this stuff? So called regex?

^.(godina: \d+|god. |).$

I guess this is it?

Yeah, you’re right! Here’s a good place to start

Thank you for the link!

Hi, I have another tricky case. My input file looks like this:

And by using reader I get this:

1.Why are the zero digits on the first several dates skipped?
2.How to trick software to read PREC right, all in one colum, despite that there are various number of spaces between the date and the value?

  1. because the node reads them as integers, so it skips the leading zeroes
  2. I think you’d better read the file with the “Line Reader” node and then split each line using a regex (again!). Something like this should work:

(\d+) captures the dates, (\d+\.\d+){0,1} captures PREC value, or a missing case

Thanks, I tried it but it duesn`t return any result.

Then I tried regex tester and it said something was wrong with this ^ character.

Then I removed it and it worked in the tester

but still nothing in Knime.
Any ideas why?

because the string " 01011991 etc." begins with a space. My fault, I didn’t noticed that. ^\s*(\d+)\s+(\d+\.\d+){0,1}.*$ should work. But maybe you’d better upload an example file for me to test it.

Hi, that worked instantly. Thanks. In the following step I wanted to read the date so I used string to date&time node and now that doesn`t work. At least that should have been simple

Maybe the regex node captures leading/trailing blanks in the first group of characters (the date). Did you use exactly the same string I wrote above?

Yes I have used the same one.

You were right again :slight_smile: It worked !

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.