Padding out question

Help with writing and playing macros

Padding out question

Postby adrianm » Thu Nov 16, 2006 12:36 pm

Hello - I am using UE32 9.10a
I am working with a large pipe delimited file and am using the Column>Convert to Fixed Width function.
I am having trouble with one column where a row of numbers is varying in length between the pipes. The third column should be 16 bytes long.
Is there anyway I can 'pad' it out so that zero's are inserted at the end of each string of numbers. e.g. this is what i have got at the moment
10||1234567|||blahblah
10||123456|||blahblah
10||123456789|||blahblah

This is what I want to see
10||1234567890000000|||blahblah
10||1234567890000000|||blahblah
10||1234567890000000|||blahblah

Any ideas would be great!
thanks
User avatar
adrianm
Newbie
 
Posts: 6
Joined: Wed Nov 15, 2006 12:00 am

Re: Padding out question

Postby Mofi » Thu Nov 16, 2006 4:12 pm

I guess, you want this result:

10||1234567000000000|||blahblah
10||1234560000000000|||blahblah
10||1234567890000000|||blahblah

You can do that with a sequence of regular expression search and replaces as following macro shows.

The macro property Continue if a Find with Replace not found must be checked for this macro.

InsertMode
ColumnModeOff
HexOff
UnixReOff
Top
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^10|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^100|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^1000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^10000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^100000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^1000000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^10000000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^100000000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^1000000000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^10000000000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9][0-9]^)|"
Replace All "^100000000000|"
Find RegExp "%^(*||[0-9][0-9][0-9][0-9]^)|"
Replace All "^1000000000000|"
Find RegExp "%^(*||[0-9][0-9][0-9]^)|"
Replace All "^10000000000000|"
Find RegExp "%^(*||[0-9][0-9]^)|"
Replace All "^100000000000000|"
Find RegExp "%^(*||[0-9]^)|"
Replace All "^1000000000000000|"

Add UnixReOn at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4039
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Padding out question

Postby adrianm » Thu Nov 16, 2006 4:37 pm

Hey that's great !
Thank yoU!
User avatar
adrianm
Newbie
 
Posts: 6
Joined: Wed Nov 15, 2006 12:00 am


Return to Macros