Skip to main content
Solved

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

  • May 26, 2021
  • 5 replies
  • 19 views

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?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+62

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

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+62

@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+46
  • 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

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