Add leading zero to field from csv

Kladkul

Member
I'm having trouble with a field that I'm reading in from a .csv and loading into a temp-table. The field can (and does) contain characters and integers so the datatype is character for the temp-table field. The only problem is I can't figure out how to add a leading zero for an integer that is 0-9.

Example: .csv value: 5
temp-table value: 5 - I need a way to have this be 05. Is there a quick and easy way to do this?
 

LarryD

Active Member
Maybe something like this? (indenting was removed as I posted this)

if length(tmptable.field) = 1
then do:
myint = int(tmptable.field) no-error.
if NOT error-status:error
then
tmptable.field = string(myint,"99").
end.
 

tamhas

ProgressTalk.com Sponsor
A simple and consistent way to pad a string with any characters is to concatenate a string of that character long enough for the longest pad to the string and then take the N rightmost characters in the result using length() and substring().
 
Top