Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

420.Advanced search and replace -- How to convert numbers into scientific format with specified spacing?

User: Chris Sokolowski -- 2010-02-12
Hits: 102
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
I need to take a document filled with floating point numbers, grouped into categories of three per line with spaces between them, divide them by 10^9 (i.e. 1000000000), and convert the numbers into scientific format (i.e. with exponents) with three spaces between each number. Thanks for the help in advance!
Input Sample:
2.20644 25.71760 35.70799
2.09604 26.11813 34.22509
1.07756 27.19535 33.80809
Output Sample:
0.220644D-10 0.2571760D-09 0.3570799D-09
0.209604D-10 0.2611813D-09 0.3422509D-09
0.107756D-10 0.2719535D-09 0.3380809D-09
Answer:
Hint: You need to Download and install "Replace Pioneer" to finish following steps.
1. ctrl-o open your source text file
2. ctrl-h open 'replace' window
* set 'replace unit' to 'Chars'
* set 'replace scope' to 'Line'
* uncheck 'Print unmatch unit' option
* in 'search for pattern', enter:

* in 'replace with pattern', enter:

3. click 'Replace', done!
4. ctrl-s save to file.

Note:
sprintf("%e   %e   %e",$1/(10**8),$2/(10**8),$3/(10**8)) will generate output of standard scientific format like:

2.206440e-008   2.571760e-007   3.570799e-007

replace(sprintf(xxxx), '(\d)\.(\d+)e(.)0','0.$1$2D$3') will change the format to:

0.2206440D-08   0.2571760D-07   0.3570799D-07



Download Script:  scripts/420.rst.zip

Similar Examples:
How to convert the text format by user specified rules? (63%)
How to change text file format with user specified rules? (56%)
How to sort all lines of text by specified keyword? (51%)
How to convert columns of data into SQL statement for mysql database? (50%)
How to change the number part of many filenames by adding some specified value? (50%)
How to change all negative numbers to the format of (number)? (50%)
How to convert each line of a text file to the new format? (50%)
How to reset all the numbers with format id=NNN in a text file?  (50%)

Check Demo of Advanced search and replace