Question

How to extract values from comma separated list?

  • 21 January 2020
  • 2 replies
  • 81 views

Badge

Hello,

I would like to extract attributes from a text file. The texfile contains different attributes separated by comma (,). It is like:

104.474,104.474,649621.0654572968,245370.49979405673,0,0,146

I tried this regex , but it gives back . delimited values (like: 474,104)

(\\d+)(,\\s*\\d+)*

Thanks!


2 replies

Userlevel 2
Badge +16

Have a look at the AttributeSplitter transformer.

After reading the text line by line, this will get you the attribute values in a list.

Then the AttributeManager can convert them to the named attributes you want.

Hope this helps.

Badge +3

1. Try using a CSV Reader instead of TextFile Reader

2. If still needing to use a TextFile Reader, use an AttributeSplitter instead of RegEx

Reply