Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing a . and a £ into text

Status
Not open for further replies.

maxcrook

Programmer
Jan 25, 2001
210
GB
I need to put a . (decimal point) into a text file that has 2 figures in it. One figure is to 2 decimal places, the other is to 3. I then need to add a pound symbol to the front of the each figure

ie

Amount=123456 (to 2.dp) - Would become £1234.56
Amount=1234567 (to 3.dp) - Would become £1234.56

Thanks

Max
 
Hi, maxcrook!

I don't understand quite your question, but I have some suggestion.

Maybe your file looks like this:

Amount=123456
Amount=1234567

In that case you can use this awk solution to format values:

awk '{ printf "Amount=£%d.%d\n", substr($1,8,4), substr($1,12,2) }' file

This solution always takes first 6 digits and makes decimal number.

So, this is just an idea, but not final answear of your question.

If your file looks like this

Amount=123456 (to 2.dp)
Amount=1234567 (to 3.dp)

I can post you another simple awk solution.

Hope this helps.

KP.
 
Thanks that is a start - what i really meant was:

The file contains 2 amounts the first one is streamed as data to 2dp, the 2nd is printed to 3 dp as the data in the tables it queries is set to this.

Therefore

amount: 123456 (to 2.d.p I would like it to read = £1234.56)
amount: 1234567 (to 3.dp would read as 1234.567 I want this though to read as 1234.56)

The script or awk command would need to look at the last 2 figures on the 1st amount and insert a . and a £ at the beginning. The next would count in 3 places place a . and place a £ at the beginning.

Hope this makes some sort of sense.
 
The data file looks like this:

MAXWEL BILL DATA STREAM CHECKS
------------------------------
/u11/maxwel/croo/bill/export/exp_8_183_1: 8 a/c, invoices total 1234567

POST-PROCESSOR CHECKS
---------------------
/u11/maxwel/croo/post_processor/output/exp_8_183_1: 8 a/c, invoices total 1234567

MAXWEL BILLSUMMARY TOTAL FOR 02-JUN-01
SUM(BALANCE_OUT_MNY)
--------------------
12345678
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top