Is there an easy way to do this?

Code:
input_from_file = 'm="12+08.00x" m="17+254." m="1298+6.000xd"'
find_expressions = re.compile(r'([\d]+[+][\d]+)')

sums = []

for m in re.finditer(find_expressions, input_from_file):
    this_expr = m.group(1)
    values = this_expr.split('+')
    sums.append(str(int(values[0]) + int(values[1])))

print sums

# outputs ['20', '271', '1304']
 


Code:
input_from_file = 'm="12+08.00x" m="17+254." m="1298+6.000xd"'
find_expressions = re.compile(r'([\d]+[+][\d]+)')

sums = []

for m in re.finditer(find_expressions, input_from_file):
    this_expr = m.group(1)
    values = this_expr.split('+')
    sums.append(str(int(values[0]) + int(values[1])))

print sums

# outputs ['20', '271', '1304']

thanks - how would I run this?
 
^^ just save that in a file called something.py, and use the file open command in my previous sample to open your file and read the data into a variable called "input_from_file".

Run it with "python something.py" on the command line.

You can output it to a file as well, if you use the previous code sample as an example.

If you're on a Mac/Linux, then Python is already installed. I don't think its too difficult to install on Windows.
 
Thanks all. Here's a better description:

I have lots of cases of the following in the document:

m="12+28.00x"

I just want to add all numbers before the + sign with the number immediately after the + sign, but before the period. That's all.

In this case the result would be m="40.00x"

the piece of info you're leaving out that would enable us to tell if excel would do it is whether the format of the "document" you refer to is column form or some other form. if all the instances of m='12+28.00' are in a single column when you put them into excel, its easy (you can look at either my previous post or NickCR's, they say pretty much the same thing). otherwise, if the m='12+28.00' strings occur randomly in some paragraph format like it was created in word or notepad, excel won't help you. good luck.
 
np, wickedDUDE

Here's the whole script:

Code:
import re

input_file = open('wf.txt', 'r')
input_from_file = input_file.read()
input_file.close()

find_expressions = re.compile(r'([\d]+[+][\d]+)')
sums = []
for m in re.finditer(find_expressions, input_from_file):
    this_expr = m.group(1)
    values = this_expr.split('+')
    sums.append(str(int(values[0]) + int(values[1])))

output_content = ""

for this_sum in sums:
    output_content += this_sum + "\n"

output_file = open('wf-output.txt', 'w')
output_file.write(output_content)
output_file.close()


First, make sure you have Python installed. Just go to the console and type 'python' and then you should see ">>>" or something very similar.

Second, save the script above in a file called 'wf.py'. Next, make sure your input file is in the same directory as 'wf.py' and save it with the file name 'wf.txt' (make sure it is a text file).

Then, at the command line type 'python wf.py'. Your sums will be on one line each in the file 'wf-output.txt'. You don't need to create that file, it will be created by the script.
 
How would this be done in regex?

[\d]+[+][\d]+

Thanks all. Here's a better description:

I have lots of cases of the following in the document:

m="12+28.00x"

I just want to add all numbers before the + sign with the number immediately after the + sign, but before the period. That's all.

In this case the result would be m="40.00x"
to get the output you describe above, change the second 'int' to 'float' in 'sums.append(str(int(values[0]) + int(values[1])))'

and change the print statement to include whatever you're looking for...

print 'm=" + val + '"x\n'
 
pinchyfingers, I definitely owe you some beers for going out of your way. I don't have python installed and i'm on a work machine, so I'm unable to install it unfortunately.
 
OP, this is a problem you have to solve once (probably). You will not learn anything which you will use in future (probably). You already spend few hours solving it (probably), engaging others on the way. Why don't you simply pay someone to do it?
 
Ok so you wanted an easy solution? Here put this code into a php file on a web server.

Page contains 3 fields; delimiter, column number and upload file.

Delimiter is the character separating the two values you want to add together.

The column number is the column number in excel that you want to process.

Working version here: http://www.nicholasaron.com/fieldAddition.php

Code:
<?php

$delimiter = '+';
$desiredCol = 3;
$dataNew = array();

if (isset($_POST['desiredCol'])) {
    $desiredCol = filter_var($_POST['desiredCol'], FILTER_SANITIZE_NUMBER_INT);
}

if (isset($_POST['delimiter'])) {
    $delimiter = filter_var($_POST['delimiter'], FILTER_SANITIZE_NUMBER_INT);
}

if (count($_FILES) > 0) {
    $fileName = $_FILES['file']['name'];
    $tmpFile = $_FILES['file']['tmp_name'];

    if (($fp = fopen($tmpFile, "r")) !== FALSE) {
        while (($data = fgetcsv($fp, 1000, ",")) !== FALSE) {
            // Lets separate the values
            $values = explode($delimiter, $data[$desiredCol - 1]);
            // Lets sanitize the values (removes everything but .'s and #'s
            $first = filter_var($values[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
            $second = filter_var($values[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
            // Lets join them and change the fields
            $total = $first + $second;
            $data[$desiredCol - 1] = number_format($total,2);
            $dataNew[] = $data;
        }
        fclose($fp);
    }

    if (($fp = fopen($tmpFile, "w")) !== FALSE) {
        foreach ($dataNew as $data) {
            $row = implode(",", $data);
            fwrite($fp, $row . "\r\n");
        }
        fclose($fp);
        $complete = true;
    }

    if ($complete) {
        // Headers should force download of file
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=\"$fileName\"");
        readfile($tmpFile);
        exit();
    }
}
?>
<html>
    <body>

        <form action="" method="post" enctype="multipart/form-data">
            <label for="file">Delimiter:</label>
            <input type="text" name="delimiter" id="delimiter" size="5" value="<?php echo $delimiter ?>" />
            <br />
            <label for="file">Desired Column:</label>
            <input type="text" name="desiredCol" id="desiredCol" size="5" value="<?php echo $desiredCol ?>" /> (1 is the first column)
            <br />
            <label for="file">Filename:</label>
            <input type="file" name="file" id="file" /> 
            <br />
            <input type="submit" name="submit" value="Submit" />
        </form>

    </body>
</html>