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


Groups > comp.lang.python > #33970

Re: Compare list entry from csv files

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <tolidtm@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'algorithm': 0.03; 'beginner': 0.05; '%s"': 0.07; 'filename': 0.07; '#print': 0.09; 'cursor': 0.09; 'must,': 0.09; 'other,': 0.09; 'rows': 0.09; 'subject:files': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'csv': 0.16; 'mechanism.': 0.16; 'row': 0.16; 'stuff,': 0.16; 'suppose.': 0.16; 'tradition': 0.16; 'wrote:': 0.17; 'comparing': 0.17; 'bit': 0.21; 'import': 0.21; 'exceptions': 0.22; 'help.': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'second': 0.24; 'pass': 0.25; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'fixed': 0.28; 'subject:list': 0.28; 'decide': 0.28; 'case,': 0.29; 'probably': 0.29; "i'm": 0.29; 'figure': 0.30; 'code': 0.31; 'file': 0.32; 'print': 0.32; 'extract': 0.33; 'problem': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'wrong': 0.34; 'third': 0.34; 'thanks': 0.34; 'nov': 0.35; 'text.': 0.35; 'doing': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'next': 0.35; 'add': 0.36; 'created': 0.36; 'but': 0.36; 'compare': 0.36; 'should': 0.36; 'too': 0.36; 'skip:p 20': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'sure': 0.38; 'delete': 0.38; 'step': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'end': 0.40; 'think': 0.40; 'your': 0.60; 'most': 0.61; 'first': 0.61; 'programs,': 0.71; 'tel': 0.75; 'phones:': 0.84; 'understand,': 0.84; 'angel': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=qFDFYnrUSrHCx9MHj+hvOD858lMQpRuG71mECyjE28Q=; b=E2RriSe+qEHm9zG3T3xeKHAShIB6DHcLOAu+pMSBNoO9tyEJ2jCNrVNOt/CtK3IIqp ZcK57q4kqeBhvTc3sh299B1CGpnSgKTdZUqJN137DyrcAMoVokVNZeJCh46bg1zdcW6i gbfln0lbJHZYrmYLOwM6afTEEpduU19xwRUXMdUTTS83UOLT+cwhkfUQm2Ok0F7azUFB sL7Zlk+TYTdozFm1kybjxNIPzTgkO8KTRua2l+wDYNJjrpcZ8Q5K0sVzER7pudPTFQhR tiOH242NuH+jiJim0pPmYfYYeLM6tS7yC4jsX8DK/WmS+QCSCIrw3s19UimXiAkIC0/L Klzg==
MIME-Version 1.0
In-Reply-To <50B43246.2010902@davea.name>
References <CAKhY55M3iOhhMbn=VuwJ7OMz_JUHVxwGy1h_BDpfBY8jQ5aRkA@mail.gmail.com> <50B3E865.9070700@davea.name> <CAKhY55OUNvGFhCjZLS7HNoDydKqHxZrnaN+bWySCsmKSk1vqsw@mail.gmail.com> <50B43246.2010902@davea.name>
Date Tue, 27 Nov 2012 15:24:55 +0100
Subject Re: Compare list entry from csv files
From Anatoli Hristov <tolidtm@gmail.com>
To d@davea.name
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.313.1354026304.29569.python-list@python.org> (permalink)
Lines 75
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1354026304 news.xs4all.nl 6979 [2001:888:2000:d::a6]:43846
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33970

Show key headers only | View raw


On Tue, Nov 27, 2012 at 4:23 AM, Dave Angel <d@davea.name> wrote:
> On 11/26/2012 05:27 PM, Anatoli Hristov wrote:
>> I understand, but in my case I have for sure the field "Name" in the
>> second file that contains at least the first or the last name on it...
>> So probably it should be possible:)
>> The Name "Billgatesmicrosoft" contains the word "Gates" so logically I
>> might find a solution for it.
>>
>
> (Please don't top-post.  Or if you must, then delete everything after
> your post, as I'm doing here.  Otherwise you end up with insanities like
> new stuff, quote-4, quote-1, quote-3, quote-2.  In this case, long
> tradition on this forum and many like it work well, even if Microsoft
> mail programs and some others decide to put the cursor at the wrong end
> of the existing text.  In most programs, it's configurable.)
>
> If you can come up with an algorithm for comparing first+last in one
> file to name in the other, then the problem can be solved.  But you
> can't do it by hand-waving, you have to actually figure out a mechanism.
>  Then we can help you code such a thing.  And I can just about guarantee
> that if these fields are created independently by human beings, that
> there will be exceptions that have to fixed by human beings.
>
>
> --
>
> DaveA

Thanks for your help. I will do my best for the forum :)

I advanced a little bit with the algorithm and at least I can now
extract and compare the fields :)
For my beginner skills I think this is too much for me. Now next step
is to add the second field with the number to the Namelist and copy it
to a third filename I suppose.

import csv

origf = open('c:/Working/Test_phonebook.csv', 'rt')
secfile = open('c:/Working/phones.csv', 'rt')

phonelist = []
namelist = []

names = csv.reader(origf, delimiter=';')
phones = csv.reader(secfile, delimiter=';')
for tel in phones:
    phonelist.append(tel)

#print "*"*25,phonelist,"*"*25
rows = 0

def finder(name_row):
    for ex_phone in phonelist:
#        phonelist.append(tel)
        telstr = ex_phone[0].lower()
#        print "*"*25 + " I got %s" % telstr
#        print "\nGot name from Name_Find :%s" % name_row
        if telstr.find(name_row) >= 0:
            print "\nName found: %s" % name_row
        else:
            pass
    return
#            print "\nNot found %s" % name_row

def name_find():

    for row in names:
        namelist.append(row)
        name_row = row[0].lower()
#        print "\nExtracted Name is :% s" % name_row
        finder(name_row)
#        name_find()
#    rows = rows +1
name_find()

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Compare list entry from csv files Anatoli Hristov <tolidtm@gmail.com> - 2012-11-27 15:24 +0100
  Re: Compare list entry from csv files Neil Cerutti <neilc@norwich.edu> - 2012-11-27 15:05 +0000
    Re: Compare list entry from csv files Anatoli Hristov <tolidtm@gmail.com> - 2012-11-27 19:57 +0100
      Re: Compare list entry from csv files Neil Cerutti <neilc@norwich.edu> - 2012-11-27 20:41 +0000
        Re: Compare list entry from csv files Anatoli Hristov <tolidtm@gmail.com> - 2012-11-29 11:22 +0100
        Re: Compare list entry from csv files Thomas Bach <thbach@students.uni-mainz.de> - 2012-11-29 13:07 +0100
        RE: Compare list entry from csv files "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-29 23:13 +0000
        Re: Compare list entry from csv files Dave Angel <d@davea.name> - 2012-11-29 22:17 -0500
        Re: Compare list entry from csv files Anatoli Hristov <tolidtm@gmail.com> - 2012-11-30 10:26 +0100
        Re: Compare list entry from csv files Anatoli Hristov <tolidtm@gmail.com> - 2012-11-30 10:29 +0100
    Re: Compare list entry from csv files Dave Angel <d@davea.name> - 2012-11-27 14:59 -0500

csiph-web