| Hello I hope this will be clearer here is the script : #################################### # -*- coding: utf-8 -*- import csv lines = csv.reader(open("CATEGORY.csv","r")) lines2 = csv.reader(open("CATEGORYLIST.csv","r")) old_cats = [] for line in lines: print line stories = [] for line2 in lines2: print "\t%s == %s ? %s" % (line2[1], line[0], line2[1] == line[0]) if line2[1] == line[0]: stories.append(line2[0]) old_cats.append((line[0],line[2], stories)) #################################### here's the output : ['100701', '22', 'Water softeners', '2', '0', '100401'] 21092 == 100701 ? False 100418 == 100701 ? False 100440 == 100701 ? False 100405 == 100701 ? False 100704 == 100701 ? False 21079 == 100701 ? False 21081 == 100701 ? False 21075 == 100701 ? False 21085 == 100701 ? False 21076 == 100701 ? False 21082 == 100701 ? False 21085 == 100701 ? False 21092 == 100701 ? False 100396 == 100701 ? False 100700 == 100701 ? False 100335 == 100701 ? False 100335 == 100701 ? False 100420 == 100701 ? False 100421 == 100701 ? False 100335 == 100701 ? False 100337 == 100701 ? False ['100702', '22', 'Garment processing', '2', '0', '100491'] ['100703', '22', 'Fume hoods', '2', '0', '100441'] ['100704', '22', 'Tank vent breathers', '2', '0', '100405'] ['100705', '22', 'Absorbent paper', '2', '0', '100438'] ['100706', '22', 'Packaging machinery & equipment', '2', '0', '100403'] ['100707', '22', 'Copper', '2', '0', '100428'] ['100708', '22', 'Silver', '2', '0', '100428'] ['100709', '22', 'Clinical waste disposal', '2', '0', '100418'] ['100710', '22', 'Air decontamination systems', '2', '0', '100342'] ['100711', '22', 'Instrument cleaner-processors', '2', '0', '100438'] ['100712', '22', 'Pathogen identification', '2', '0', '100404'] ['100713', '22', 'Biocidal wipes', '2', '0', '100517'] ['100714', '22', 'Medical devices', '2', '0', '100418'] ['100715', '22', 'Testing', '2', '0', '100491'] when can see that the inner loop is only executed for the first item of the top-level loop... I've attached the 2 CSV files. Thanks |
CATEGORYLIST.csv
Description: Binary data
CATEGORY.csv
Description: Binary data
Begin forwarded message:
----------------------------------------------------------------------------------------------- This e-mail (and any attachments) is confidential and may contain personal views which are not the views of Cimex Media Ltd and any affiliated companies, unless specifically stated. It is intended for the use of the individual or group to whom it is addressed. If you have received it in error, please delete it from your system, do not use, copy or disclose the information in any way nor act in reliance on it and please notify [email protected] A company registered in England Wales. Company Number 03765711 Registered Office : The Olde Bakehouse, 156 Watling Street East, Towcester, Northants NN12 6DB This email was scanned by Postini, the leading provider in Managed Email Security. |
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
