I'm trying to go thru a file with product codes and rateband prices and quantities
(productcode, pricea, qtya, priceb, qtyb, pricec, qtyc, priced, qtyd, pricee, qtye).
For a certain group of up to 4 productcodes I need to sum up the values of the price cells after testing the qty
fields have the same values.
Because I don't have any experience with python I was wondering what the most elegant way would be to do this in python.
biscayne 0 Light Poster
Recommended Answers
Jump to PostYou can go from there:
# data format: # productcode, pricea, qtya, priceb, qtyb, # pricec, qtyc, priced, qtyd, pricee, qtye data = '''\ aa,10,5,9,10,8,50,7,100,6,500 ab,10,5,9,10,8,50,7,100,4,500 ba,10,5,9,10,8,50,8,100,6,500 bb,10,5,9,10,8,50,6,100,6,500 ca,10,5,9,10,8,50,7.5,100,6,500 cb,10,5,9,10,8,50,7.3,100,6,500 cc,10,5,9,10,8,50,7.2,100,6,500 ''' fname = "price_data.csv" # write the test file with open(fname, "w") as fout: fout.write(data) # …
All 4 Replies
rrashkin 41 Junior Poster in Training
biscayne 0 Light Poster
Lardmeister 461 Posting Virtuoso
biscayne 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.