# Country,Competent Authority,Approval Number,Trading name,Address 1,Address 2,Adress 3,Town/Region,Postcode,Section 0,Section I,Section II,Section III,Section IV,Section V,Section VI,Section VII,Section VIII,Section IX,Section X,Section XI,Section XII,Section XIII,Section XIV,Section XV,Section XVI,Species,Remarks,Address withheld,uprn,lat,lng,match_score,match_description fields = ["food-premises", "premises", "name", "business", "start-date", "end-date"] writer = Writer(sys.stdout, fields) reader = csv.DictReader(sys.stdin) for num, row in enumerate(reader): uprn = row["uprn"] name = row["Trading name"] if uprn and row["Address withheld"] != "Y": item = Item() item.__dict__["food-premises"] = uprn if uprn in uprns: item.premises = uprns[uprn] if name in companies: if companies[name]: item.business = "company:" + companies[name] item.__dict__["end-date"] = "" item.name = row["Trading name"] writer.write(item) writer.close()