473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Processing and adding numbers from lines.

Hello, Group:

Is there an easy way to automate the processing of adding the following
numbers in two lines?

test test test description (100-10-0, 6700 test)
test test test description (100-10-0, 6350 test)

I'd like to be able run a script on the file above to produce the
following results.

200-20 .9090

The lines will stay the same, but the numbers will change. I'd like to
be able copy and paste the lines into an html form to process the
results.

Regards,

--SF

Jan 5 '06 #1
6 1265
NC
sa*********@gmail.com wrote:

Is there an easy way to automate the processing of adding the following
numbers in two lines?

test test test description (100-10-0, 6700 test)
test test test description (100-10-0, 6350 test)
Yes. You can get all numbers out of the string using regular
expressions or a simple explode()...
I'd like to be able run a script on the file above to produce the
following results.

200-20 .9090


How do you arrive at .9090?

Cheers,
NC

Jan 5 '06 #2
NC:

..90 is the percent that 20 is of 220. Do you have a sample that might
lead me the right direction? I'm not very good with regular expersions
that involve processing lines with data the needs to be thrown out.

--SF

Jan 5 '06 #3
NC:

..90 is the percent that 20 is of 220. Do you have a sample that might
lead me the right direction? I'm not very good with regular expersions
that involve processing lines with data the needs to be thrown out.

--SF

Jan 5 '06 #4
NC:

..90 is the percent that 20 is of 220. Do you have a sample that might
lead me the right direction? I'm not very good with regular expersions
that involve processing lines with data the needs to be thrown out.

--SF

Jan 5 '06 #5
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

sa*********@gmail.com wrote:
Is there an easy way to automate the processing of adding the following
numbers in two lines?

test test test description (100-10-0, 6700 test)
test test test description (100-10-0, 6350 test)


sscanf.

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

Por su pico, se pierde el pajarico.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDvY3f3jcQ2mg3Pc8RAvk8AJ9oiEgHNFkkqMMsp6PFmd jpJhAekgCfYvXH
WWxL9mLBW8f/Ync6nnycSgo=
=ffC7
-----END PGP SIGNATURE-----
Jan 5 '06 #6
NC
sa*********@gmail.com wrote:

.90 is the percent that 20 is of 220.
Not really... 20 is 9.090909...% of 220...
Do you have a sample that might lead me the right direction?


Let's see...

$line1 = 'test test test description (100-10-0, 6700 test)';
$line2 = 'test test test description (100-10-0, 6350 test)';
list(, $temp) = explode('(', $line1);
list($temp,) = explode(',', $temp);
list($n11, $n12, $n13) = explode('-', $temp);
list(, $temp) = explode('(', $line2);
list($temp,) = explode(',', $temp);
list($n21, $n22, $n23) = explode('-', $temp);
echo $n11+$n21, '-', $n12+$n22, ' ',
number_format(1-($n12+$n22)/($n11+$n21+$n12+$n22),4);

That's it, really...

Cheers,
NC

Jan 6 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: sp0 | last post by:
Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think
23
by: Daniel Rudy | last post by:
Hello, I'm trying to learn how command line arguments are handled in C. The following code segment that I wrote as a test program compiles, but when I try to run it, it core dumps. This is...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
6
by: Hareth | last post by:
Scenerio: label1.text = 0 textbox1.text = 0 textbox2.text = textbox1.text + label1.text It turns out it isnt adding the numbers, it attaches the new number next to the old number
3
by: tai.cabrera | last post by:
What I would like to do is input a range of serial numbers in a form and have that range populate in the table without me having to put them in one at a time manually. The numbers do not exist yet,...
1
by: sanfranc415 | last post by:
Hello, Group: Is there an easy way to automate the processing of adding the following numbers in two lines? test test test description (100-10-0, 6700 test) test test test description ...
17
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
9
suzee_q00
by: suzee_q00 | last post by:
I will admit that lots of times the obvious eludes me and this is most likely one of those times but if anyone has any ideas on what I can do to make this code work, I would greatly appreciate it....
60
by: Bill Cunningham | last post by:
I have a row of values like such, placed in a text file by fprintf. 10.50 10.25 10.00 10.75 11.00 What I want to do to the above colum is add a new column right beside it which is a total...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.