473,396 Members | 1,895 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,396 software developers and data experts.

Problem with computing...addition

Hi Folks,
I have some code, have tested the output, and I have seen the mess !!!!

here the code:

def fee(data):
from re import sub, findall
from string import join, split
fee = sub('.*?EUR', '', data)
fee = findall('.*,..', fee)
print fee
zwischensumme = float("0")
for i in range(int(len(fee))):
fee[i] = join(split(fee[i], ","), ".")
fee[i] = float(fee[i])
zwischensumme = zwischensumme + fee[i]
print zwischensumme
print zwischensumme
print int(len(fee))
print fee
def main(data,vendor,type):
print data
fee(data)
it begins in the main(). the output of "print data" in main is:

-------------cut -----------------
* Nokia 6610 NEU & OVP * 2 Jahre Garantie * EUR 198,0016 18Min
Nokia 6610 + Camera Headset HS-1C ** NEU ** EUR 221,0033 1Std
17Min
NOKIA 6610 NEU + OVP + GARANTIE !!ANGUCKEN!!! EUR 181,0012 1Std
57Min
Nokia 6610 OVP *neu* EUR 176,0025 17Std 35Min
Nokia 6610, OVP, neu EUR 126,622 21Std 12Min
Nokia 6610, Originalverpackt, WIE NEU !! EUR 113,0010 21Std
39Min
Nokia 6610 ***NEU*** EUR 329,00- 21Std 42Min
+++NOKIA 6610 NEU in OVP in grau+++ EUR 133,00101T 00Std 57Min
NOKIA 6610 NEU OVP GARANTIE RECHNUNG !! EUR 151,0061T 01Std 12Min
Nokia 6610 NEU OVP 24 Monate Garantie EUR 152,0081T 01Std 30Min
NOKIA 6610 BLACK NEU und OVP KEIN VERTRAG !!! EUR 152,00161T 01Std
50Min
Nokia 6610 - NEU EUR 152,0081T 02Std 28Min
* NOKIA 6610 NEU*OVP*Silber*GARANTIE*Headset* EUR 152,0091T 02Std
39Min
Nokia 6610 (NEU/OVP/ 2 JAHRE GARANTIE) EUR 152,00111T 02Std 44Min
* Nokia 6610 grey * NEU + OVP + 2 J. Garantie EUR 131,99121T 02Std
49Min
Nokia 6610 Neu ohne SimLock OVP mit Camera EUR 153,27231T 03Std
49Min
NOKIA 6610, NEU, Ungebraucht, Silber!!! EUR 175,00-1T 18Std 14Min
---------------- cut -----------

everything in front of "EUR" is cut off.
the fee is searched, and printed. the output of <fee> is:

[' 198,00', ' 221,00', ' 181,00', ' 176,00', ' 126,62', ' 113,00', '
329,00', ' 133,00', ' 151,00', ' 152,00', ' 152,00', ' 152,00', ' 152,00',
' 152,00', ' 131,99', ' 153,27', ' 175,00', ' 175,00', ' 68,00', ' 45,50',
' 26,50', ' 71,00', ' 152,00', ' 61,00', ' 101,00', ' 259,00', ' 151,00', '
20,50', ' 1,00', ' 66,00', ' 200,00', ' 200,00', ' 1,00', ' 81,00', '
1,00', ' 1,00', ' 25,50', ' 53,00', ' 240,00', ' 1,00', ' 25,50', ' 1,50',
' 101,00', ' 3,05', ' 1,00', ' 239,00', ' 15,50', ' 1,00', ' 10,00', '
1,99']

so everything seems to be ok now....
but ...
after the "," is changed to an "." and the field of the list is converted to
float, the output looks like this:

[198.0, 221.0, 181.0, 176.0, 126.62, 113.0, 329.0, 133.0, 151.0, 152.0,
152.0, 152.0, 152.0, 152.0, 131.99000000000001, 153.27000000000001, 175.0,
175.0, 68.0, 45.5, 26.5, 71.0, 152.0, 61.0, 101.0, 259.0, 151.0, 20.5, 1.0,
66.0, 200.0, 200.0, 1.0, 81.0, 1.0, 1.0, 25.5, 53.0, 240.0, 1.0, 25.5, 1.5,
101.0, 3.0499999999999998, 1.0, 239.0, 15.5, 1.0, 10.0, 1.99]

So you see e.g. the 15th entry: "131.99000000000001"

there should be "131.99" and not this.
who could help?
--
---------------------------------------------------------
Das einzige Mittel gegen Aberglauben ist Wissenschaft.
(Henry Thomas Buckle)
Jul 18 '05 #1
2 1317
In article <bh*************@ID-202203.news.uni-berlin.de>,
Lukas Kasprowicz <ma******@gmx.de> wrote:

So you see e.g. the 15th entry: "131.99000000000001"
there should be "131.99" and not this.

who could help?


http://www.python.org/doc/current/tut/node14.html
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
Jul 18 '05 #2
Thank you

Aahz wrote:
In article <bh*************@ID-202203.news.uni-berlin.de>,
Lukas Kasprowicz <ma******@gmx.de> wrote:

So you see e.g. the 15th entry: "131.99000000000001"
there should be "131.99" and not this.

who could help?


http://www.python.org/doc/current/tut/node14.html


--
---------------------------------------------------------
Das einzige Mittel gegen Aberglauben ist Wissenschaft.
(Henry Thomas Buckle)
Jul 18 '05 #3

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

Similar topics

10
by: JMorrell | last post by:
First post to this community so am not sure if this is the correct place. Here goes. I have a MS Access db that keeps track of employees sick and annual leave balances. In it, I have a report,...
10
by: Michael G | last post by:
double A = floor((2447297.0 - 122.1)/365.25); i get differing results. It varies between 6699 and 6700. The correct answer is 6699. The 6700 result really throws the entire group of calculations...
117
by: Peter Olcott | last post by:
www.halting-problem.com
15
by: fdunne2 | last post by:
The following C-code implements a simple FIR filter: //realtime filter demo #include <stdio.h> #include <stdlib.h> //function defination float rtFilter1(float *num, float *den, float...
7
by: Greenhorn | last post by:
Hi, Is two's complement always used as a storage method or is it computed while computing the expression involved. e.g., int a = -2, b = 3, c = 4, d; d = b - c; Here, is 'a' stored as two's...
0
by: natty2006 | last post by:
Submission Deadline extended: 13 November 2006 ************************************************************* IADIS INTERNATIONAL CONFERENCE APPLIED COMPUTING 2007 February 17-20, 2007 -...
6
by: Andre Majorel | last post by:
How do you compute an off_t with overflow detection ? Ideally, the target language is C89/C90 and the target platform is reasonably recent versions of the major Unixen. If there is no practical...
14
by: Aaron Watters | last post by:
So, in between skiing runs I noticed a Business Week cover story on "cloud computing". The article had lots of interesting information in it like about how somebody's mom used to be an airline...
60
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
On May 3, 8:09 am, apati...@gmail.com wrote: A programmer that uses Vista? :O Vista is a hog of an operating system. Downgrade to Windows XP or get yourself a Linux distro.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.