Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'importing': 0.04; 'finally:': 0.05; 'try:': 0.07; 'advice?': 0.09; 'subject:files': 0.09; 'index': 0.13; 'csv': 0.16; 'name",': 0.16; 'row': 0.16; 'skip:n 50': 0.16; 'file.': 0.20; 'written': 0.20; 'trying': 0.21; 'import': 0.21; 'name;': 0.22; 'insert': 0.23; 'skip:" 20': 0.26; 'message-id:@mail.gmail.com': 0.27; 'subject:list': 0.28; "i'm": 0.29; 'lists': 0.31; 'file': 0.32; 'to:addr:python-list': 0.33; 'another': 0.33; 'entry': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'sometimes': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'compare': 0.36; 'skip:p 20': 0.36; 'received:209': 0.37; 'files': 0.38; 'skip:o 20': 0.38; 'shows': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'first': 0.61; 'phone,': 0.62; 'skip:n 10': 0.63; 'phone': 0.68; 'as:': 0.75; 'address;': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=/62a/+n74ipjMxp0bk7/FsKxi40zgCpFK65ZmVlvTg8=; b=E+oEfgghWQ+GZYH4xuZjBb+HcriEWTitnE6IS/IEn8EbGZpxAXzjpDFQ0esv3157Ke +TbRmerZrBJSA31QNowsD3uGh2Tk5jmTm6c4wdYCKoEeTvJMsQQ2xJ8neK+NTQBHLG7X ykPulLMIKrHo3bqyjina2oVLWowVg/iQrV7hh4RejinY/WO2cqOLJaeiwi/Ot/rxIVIq PEpguFdRozwZxhZN2JUucXXQuytKWYjkeY9nnrf+RIxD2rNw5cQcF/AcivxIvhF6+o0J TLLA7OHo6zn8t6hENYj2B9djTeFOXiTIe+W1JYqdl9pjyufCWuxaznvsq+Gn7CdK1fLU +TFQ== MIME-Version: 1.0 Date: Mon, 26 Nov 2012 22:08:08 +0100 Subject: Compare list entry from csv files From: Anatoli Hristov To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353964091 news.xs4all.nl 6904 [2001:888:2000:d::a6]:54800 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33945 Hello, I'm trying to complete a namebook CSV file with missing phone numbers which are in another CSV file. the namebook file is structured: First name;Lastname; Address; City; Country; Phone number, where the phone number is missing. The phonebook file is structured as: Name; phone, where the name shows first and last name and sometimes they are written together like "BillGates" or "Billgatesmicrosoft". I'm importing the files as lists ex.: phonelist" ["First name", "Last name","address","City"."Country","phone"],[etc...] in the loop I can compare the entry for ex. "Bill Gates" in the field "BillGatesmicrosoft" but I can't index it so I can only take the phone number from the file with the phones and insert it to field in the Namebook. Can you please give me an advice? Thanks import csv origf = open('c:/Working/Test_phonebook.csv', 'rt') phonelist = [] try: reader = csv.reader(origf, delimiter=';') for row in reader: phonelist.append(row) finally: origf.close() secfile = open('c:/Working/phones.csv', 'rt') phones = [] try: readersec = csv.reader(secfile, delimiter=';') for row in readersec: phones.append(row) finally: secfile.close()