Dataiku forces column type, removes leading zeros

mrs25
Level 2
Dataiku forces column type, removes leading zeros

Hello,

I am trying to store an ID column as a text/character column and not an integer column. How would I go about forcing the column type of a Dataiku Dataset? I forced it manually when viewing the dataset sample, but when I built the dataset again, it forced it back, interpreting the column as an integer instead of a character, removing the leading zeros. 

I also tried to force the column type in the code (I am using R), but it didn't work. Additionally, the same column was interpreted as a character/text column earlier in the flow, but it's interpreted differently later on in the flow in my output dataset.

Please note that no transformations are done on this particular column throughout the flow.

Thank you.

0 Kudos
5 Replies
CoreyS
Dataiker Alumni

Hi @mrs25 and welcome to the Dataiku Community. While you wait for a more complete response, in terms of padding a number with leading zeroes, I welcome you to this resource in our Knowledge Base: How to pad a number with leading zeros

I hope this helps!

Looking for more resources to help you use Dataiku effectively and upskill your knowledge? Check out these great resources: Dataiku Academy | Documentation | Knowledge Base

A reply answered your question? Mark as โ€˜Accepted Solutionโ€™ to help others like you!
mrs25
Level 2
Author

Thank you for this resource! 

However, the column has varying lengths of strings, ranging from 5-8 digits, with some requiring varying lengths of leading zeros, so unfortunately, I cannot force pad them.

0 Kudos
Jurre
Level 5

Welcome @mrs25 ,

i add a prefix-character(for example the letter z) to ID-columns with numerical values in order to save leading zero's and force a type. Cheers, -Jurre 

mrs25
Level 2
Author

Ah I see! I will try this - thank you!

0 Kudos
June
Level 3

This is a clunky workaround.  It would sure be nice if a string of numbers would just be treated as strings.