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


Groups > comp.lang.python > #44557

Re: how to compare two fields in python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joel.goldstick@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'python.': 0.02; 'subject:two': 0.07; 'kumar': 0.09; 'subject:fields': 0.09; 'cc:addr:python-list': 0.11; '203': 0.16; '509': 0.16; 'csv': 0.16; 'finds': 0.16; 'subject:compare': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'python?': 0.22; 'cc:addr:python.org': 0.22; 'example.': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'file': 0.32; 'url:python': 0.33; 'basic': 0.35; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'received:google.com': 0.35; 'module.': 0.36; 'done': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:209': 0.37; 'pm,': 0.38; 'url:mail': 0.40; 'how': 0.40; 'numbers': 0.61; 'first': 0.61; 'field': 0.63; 'different': 0.65; '30,': 0.65; 'finally': 0.65; 'here': 0.66; 'study': 0.69; 'joel': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=aXCsYXg1D3gDpWtttxy3ZhodzOKCGSHzP1vBOSssVeU=; b=MS7H1hDl/a2EwsEIUHiHrj+XLL2iiZvwwFrflzRFwoNAfKlW1EEwpNnajtriQWVbON +tVe4gTwhuKEqFUXhDXUtX7VEtDLWED4orNgzTPykns0uKrBg8ZqKG7TRJ8lH3GGsLif 3t9fZWCUdR0Poz5hq9NZ05IoKdl8oFHXTxLaKa/cbFgLC0LIIwVKbIVoa8MdOsucEI30 NaqjQmlR2k8xb4sNluMhvTNIR6SP5xCTvipK4yTdMZot3nvh697EopInc5qbCy25sHRL drwAUAhZmKlRY1XqBJ7AHBBOaVMTrtTa0SCTf+5of2rd5AsP4DMhrwZaKF++xhTEPt2c oy9g==
MIME-Version 1.0
X-Received by 10.220.95.10 with SMTP id b10mr35149164vcn.10.1367344420724; Tue, 30 Apr 2013 10:53:40 -0700 (PDT)
In-Reply-To <59afdc2b-ab76-40b6-8f63-4a562e288029@googlegroups.com>
References <59afdc2b-ab76-40b6-8f63-4a562e288029@googlegroups.com>
Date Tue, 30 Apr 2013 13:53:40 -0400
Subject Re: how to compare two fields in python
From Joel Goldstick <joel.goldstick@gmail.com>
To upendra kumar Devisetty <upendrakumar.devisetty@googlemail.com>
Content-Type multipart/alternative; boundary=001a11c1d8787ba6f604db97ae25
Cc "python-list@python.org" <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.1190.1367344424.3114.python-list@python.org> (permalink)
Lines 78
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367344424 news.xs4all.nl 15917 [2001:888:2000:d::a6]:35274
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44557

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Apr 30, 2013 at 1:41 PM, upendra kumar Devisetty <
upendrakumar.devisetty@googlemail.com> wrote:

> I have a very basic question in python. I want to go through each line of
> the a csv file and compare to see if the first field of line 1 is same as
> first field of next line and so on. If it finds a match then i would like
> to put that field in an object1 else put that field in a different object2.
> Finally i would like to count how many of the fields in object1 vs object2.
> Can this be done in python? Here is a small example.
>
> BRM_1   679 1929
> BRM_1   203 567
> BRM_2   367 1308
> BRM_3   435 509
> As you can see field1 of line1 is same as field2 of line2 and so that
> field BRM_1 should be place in object1 and BRM_2 and BRM_3 should be placed
> in object2. So the final numbers of object1 is 1 and object2 is 2.
>
>
You should study the csv module.

> Thanks in advance..
>
> Upendra
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

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


Thread

how to compare two fields in python upendra kumar Devisetty <upendrakumar.devisetty@googlemail.com> - 2013-04-30 10:41 -0700
  Re: how to compare two fields in python Joel Goldstick <joel.goldstick@gmail.com> - 2013-04-30 13:53 -0400
  Re: how to compare two fields in python Fábio Santos <fabiosantosart@gmail.com> - 2013-04-30 19:08 +0100
  Re: how to compare two fields in python Tim Chase <python.list@tim.thechases.com> - 2013-04-30 13:19 -0500
    Re: how to compare two fields in python upendra kumar Devisetty <upendrakumar.devisetty@googlemail.com> - 2013-04-30 11:22 -0700
      Re: how to compare two fields in python Fábio Santos <fabiosantosart@gmail.com> - 2013-04-30 19:42 +0100
  Re: how to compare two fields in python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-04-30 19:54 -0400

csiph-web