Separating the columns cleanly txt file from DWD

I have a problem reading in the following file or separating the columns cleanly.
(https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/daily/kl/recent/KL_Tageswerte_Beschreibung_Stationen.txt)

I have tried with FileReader, File Reader (complex Format).
Hide first lines etc.

The only solution I can think of is the Fixed Witdh File Reader, but it is not a nice solution.

Does anyone have any idea?


Ich habe ein Problem dabei die folgende Datei einzulesen bzw. die Spalten sauber zu trennen.
(https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/daily/kl/recent/KL_Tageswerte_Beschreibung_Stationen.txt)

Ich habe es mit dem FileReader, File Reader (complex Format) versucht.

Einzige Lösung die mir noch einfällt ist der Fixed Witdh File Reader,

Hat jemand eine Lösung?

hi @robbsen

the Fixed Width File Reader would be the best and imo only solution.
This should be followed by a “strip” function using the String Manipulation and Number to String (if necessary for specific columns).

Hope that helps
regards
Thomas

2 Likes

Hello robbsen,

recently I had the same issue. The problem was that headers and data rows did not align. For me it worked as follows:

  1. Use the File Reader to read the file into one single column. Make sure to use ISO-8859-1 encoding and limit the rows to the data by skipping the first two rows.
  2. Use the Cell Splitter By Position to separate columns. In my case, setting indices to “5,14,23,38,50,60,101” and column names to “station_id,start,stop,station_height,lat,lon,name,state” worked well.
  3. With String Manipulation (Multi Column) you can strip() whitespaces.
4 Likes

Looks like it works.
Thanks for your help, learned a lot again

2 Likes

Hello @robbsen,

here is another way using Line Reader and splitting on whitespace after which you use couple of manipulation nodes to get correct Bundesland and Stationsname. Useful if column position indices might change or you are lazy to count or for future data import :slight_smile:

Here is example. Take a look and if any questions feel free to ask. Welcome to KNIME Community!
2021_11_02_Column_Separating.knwf (28.0 KB)

Br,
Ivan

2 Likes

Thanks again for the help and the kind reception. Both ways work.

1 Like

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