Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33945 > unrolled thread

Compare list entry from csv files

Started byAnatoli Hristov <tolidtm@gmail.com>
First post2012-11-26 22:08 +0100
Last post2012-11-26 22:08 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Compare list entry from csv files Anatoli Hristov <tolidtm@gmail.com> - 2012-11-26 22:08 +0100

#33945 — Compare list entry from csv files

FromAnatoli Hristov <tolidtm@gmail.com>
Date2012-11-26 22:08 +0100
SubjectCompare list entry from csv files
Message-ID<mailman.298.1353964091.29569.python-list@python.org>
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()

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web