Ask Your Question

Replace all . with _ in field names

asked 2018-09-17 16:13:47 -0600

todd gravatar image

How can I replace the character . with a _ character in all field names?

I'd like to do it in Field Renamer (if possible) rather than a Groovy processor such as described here

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-09-17 16:29:19 -0600

jeff gravatar image

updated 2019-09-11 09:54:04 -0600

As of SDC 3.8.0, the Field Mapper Processor can be used to easily replace special characters in all field names in the entire record. See the documentation for an example.

Previous answer:

Did you see this Q&A? You can extend the approach described there. Also, this one is more directly related to what you're doing.

edit flag offensive delete link more


I'm regex challenged. I've found all kinds of examples for removing content from strings like the Q&A you mention, but nothing yet on replacing a char as described.

todd gravatar imagetodd ( 2018-09-17 16:33:16 -0600 )edit

Edited with a new link that is more directly relevant. You will just use '\.' instead of space and add a '_' in between the replacement parts.

jeff gravatar imagejeff ( 2018-09-17 16:37:26 -0600 )edit

When I try /'([^\.]*) ([^_]*)' in Source Field and then /$1$2 in Target, exception com.streamsets.pipeline.api.base.OnRecordErrorException: FIELD_RENAMER_00 - Record 'rawData::0' does not contain fields '/'([^\.]*) ([^_]*)'' at com.streamsets.pipeline.stage.processor.fieldrenamer.FieldRena

todd gravatar imagetodd ( 2018-09-17 16:50:33 -0600 )edit

This should work: Source Field == /'([^ ]*)\.([^ ]*)' and Target Field == /$1_$2

iamontheinet gravatar imageiamontheinet ( 2018-09-17 16:56:33 -0600 )edit

same exception but slightly different... com.streamsets.pipeline.api.base.OnRecordErrorException: FIELD_RENAMER_00 - Record 'rawData::0' does not contain fields '/'([^ ]*)\.([^ ]*)'' In case it matters, I'm using a pipleine with a Dev Raw Data Source to send through key/value pairs

todd gravatar imagetodd ( 2018-09-17 17:04:48 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-09-17 16:13:47 -0600

Seen: 563 times

Last updated: Sep 11 '19