unk-remus wrote:Does converting to fixed column have anything to do with rounding?
No! Converting to fixed column means replacing the separartor (= comma) by spaces so that every data column has same width.
- Code: Select all
100100,1841538.5998853,517594.987
100100,1841538.530,517594.987
100100,1841538.538,517594.987
The block above is for example converted to:
- Code: Select all
100100 1841538.5998853 517594.987
100100 1841538.530 517594.987
100100 1841538.538 517594.987
A rounding as you would like requires converting the value strings into floating point numbers, then round them depending on 4 post comma digit and write the rounded float value back to file as string. Spreadsheet applications like Excel support that. With an UltraEdit script it would be possible to.
But I have written here quickly an UltraEdit macro which does most of the roundings by running Perl regular expression replaces.
- Code: Select all
InsertMode
ColumnModeOff
HexOff
PerlReOn
Top
Find MatchCase RegExp "(\.\d\d\d)[0-4]\d+"
Replace All "\1"
Find MatchCase RegExp "(\.\d\d)0\d+"
Replace All "\11"
Find MatchCase RegExp "(\.\d\d)1\d+"
Replace All "\12"
Find MatchCase RegExp "(\.\d\d)2\d+"
Replace All "\13"
Find MatchCase RegExp "(\.\d\d)3\d+"
Replace All "\14"
Find MatchCase RegExp "(\.\d\d)4\d+"
Replace All "\15"
Find MatchCase RegExp "(\.\d\d)5\d+"
Replace All "\16"
Find MatchCase RegExp "(\.\d\d)6\d+"
Replace All "\17"
Find MatchCase RegExp "(\.\d\d)7\d+"
Replace All "\18"
Find MatchCase RegExp "(\.\d\d)8\d+"
Replace All "\19"
Find MatchCase RegExp "\.\d{4,}"
IfFound
Key HOME
Find MatchCase RegExp "(\.\d)09\d+"
Replace All "\110"
Find MatchCase RegExp "(\.\d)19\d+"
Replace All "\120"
Find MatchCase RegExp "(\.\d)29\d+"
Replace All "\130"
Find MatchCase RegExp "(\.\d)39\d+"
Replace All "\140"
Find MatchCase RegExp "(\.\d)49\d+"
Replace All "\150"
Find MatchCase RegExp "(\.\d)59\d+"
Replace All "\160"
Find MatchCase RegExp "(\.\d)69\d+"
Replace All "\170"
Find MatchCase RegExp "(\.\d)79\d+"
Replace All "\180"
Find MatchCase RegExp "(\.\d)89\d+"
Replace All "\190"
Find MatchCase RegExp "\.\d{4,}"
EndIf
The macro is not complete as it does not round a value like 1841538.
5998853 to 1841538.
600 or a value like
1999999.
9995013 to
2000000.
000.
In other words if a round up is necessary and second post comma digit has the value
9, the value is not rounded. The last find selects the first number where a manual round must be done if there is such a value in the file. After making this round manually, search with Perl regular expression engine for
\.\d{4,} for other values which must be rounded manually after executing this macro.