Skip to main content
Solved

BMP for setting data types upon read (or upfront)?


townest
Contributor
Forum|alt.badge.img+4

What is the best management practice for setting attribute data types prior to writers, preferably at the reader?

 

My specific issue de jour is an attribute (data e.g. 1023, 1034, 1002.1) that is reading in as real32 but indeed they need to be strings for my use case. A custom python transformer (type casting to strings) changes the values to strings '1023.0', '1034.0', '1002.1', due to real32 initial type, which won't work. I need strings '1023', '1034', '1002.1'.

 

Thanks for reading and any response is appreciated.

 

Tyler

FME Desktop 2020.2

Best answer by ebygomm

Does the string formatter not work for this use case?

View original
Did this help you find an answer to your question?

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+50

Internally FME doesn't really enforce strict data types (but specific readers and writers will). You could probably get away with using a StringReplacer to replace the regex \\.0$ with an empty string.


townest
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • May 27, 2021
redgeographics wrote:

Internally FME doesn't really enforce strict data types (but specific readers and writers will). You could probably get away with using a StringReplacer to replace the regex \\.0$ with an empty string.

@Hans van der Maarel​ , That's a bit dangerous because if I have an original value of 1000.0 it will be modified to '1000' instead of the desired '1000.0'.

 

BTW: My reader in this case is the csv reader. You mentioned some readers allow type setting. Which ones? Thank you.

 

Tyler


redgeographics
Celebrity
Forum|alt.badge.img+50
townest wrote:

@Hans van der Maarel​ , That's a bit dangerous because if I have an original value of 1000.0 it will be modified to '1000' instead of the desired '1000.0'.

 

BTW: My reader in this case is the csv reader. You mentioned some readers allow type setting. Which ones? Thank you.

 

Tyler

My mistake, I misread your original question.


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • Best Answer
  • May 27, 2021

Does the string formatter not work for this use case?


townest
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • May 28, 2021
ebygomm wrote:

Does the string formatter not work for this use case?

Yep. That did it. Just used 's' as format string. Good to go. Thank you. Tyler


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings