Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; '-----------': 0.04; '------------': 0.07; 'subject:file': 0.07; 'excluding': 0.09; 'subject:create': 0.09; 'cc:addr:python-list': 0.10; 'files.': 0.13; 'resulting': 0.13; '(the': 0.15; 'csv': 0.16; 'one)': 0.16; 'row': 0.16; 'whitespace.': 0.16; 'string': 0.17; 'wrote:': 0.17; 'thu,': 0.17; 'feb': 0.19; 'file.': 0.20; 'not,': 0.21; 'file:': 0.22; 'cc:2**0': 0.23; 'split': 0.23; 'second': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'values': 0.26; 'plain': 0.27; 'message- id:@mail.gmail.com': 0.27; 'separated': 0.29; 'url:mailman': 0.29; 'skip:- 30': 0.31; 'url:python': 0.32; 'file': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'anyone': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'third': 0.34; 'thanks': 0.34; 'list': 0.35; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'url:org': 0.36; 'method': 0.36; 'should': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'where': 0.40; 'help': 0.40; 'url:mail': 0.40; 'first': 0.61; '2013': 0.84; 'to:addr:libero.it': 0.84; 'joel': 0.91 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=+w/oxwyv36lsMNBkweHB1A4qH98CNaNMZZ9XLwvE9+k=; b=RCY99/EbfH3js2Jp/jgCwZDpn87OxrmfIH5RnKBUqnAQNdSjiUWd4h+7GYxytNASpQ D3xfGAFD3x5TDBkMKg7KsCTkndrEUvNrppHLawPC2Q/PqAgeorz/YiP+wMR8dyUmokAj n5AcpSBC+NQ4iVB5GLsP7sITxIOb6+1DExBmJa4byb/p1k62HvtTAPgGTTlhFPGUUKR/ H22gdnSfiOCYgN8njnnlvwbS3Vk50AQN//ASiJhjccYOWGqIDPgCAGpxJVYHQ4Ll0/7m KRoTDJelfFOSe5oJsP9wzO67NJQPnZH8EWE7iLJOAzoxw4Z/9QXmFxjuHEJ3v/Mptcv3 BctA== MIME-Version: 1.0 X-Received: by 10.52.23.205 with SMTP id o13mr2588198vdf.78.1362080052421; Thu, 28 Feb 2013 11:34:12 -0800 (PST) In-Reply-To: <512fac9c$0$40355$4fafbaef@reader1.news.tin.it> References: <512fac9c$0$40355$4fafbaef@reader1.news.tin.it> Date: Thu, 28 Feb 2013 14:34:12 -0500 Subject: Re: Read csv file and create a new file From: Joel Goldstick To: io Content-Type: multipart/alternative; boundary=20cf307ca364ae31cf04d6cdf9ae 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 132 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362080055 news.xs4all.nl 6959 [2001:888:2000:d::a6]:42720 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40161 --20cf307ca364ae31cf04d6cdf9ae Content-Type: text/plain; charset=UTF-8 On Thu, Feb 28, 2013 at 2:14 PM, io wrote: > Hi, > > i have to files. > > First file is a csv file > Second file is a plain text file where each row has a value (text) > Read the second file so that you have a list of each of its values Read the first file line by line. Check if the value at the beginning of the line is in the list of values from the second file. If not, print it to outfile. You should look up split method on strings to split a string separated by whitespace. > > I want to be able to create a third file using data from the first file > excluding the values listed in the second file. > > Example: > > First file: > ----------- > > mtgoxeur 12 24 36 > mtgoxusd 10 12 14 > mtgoxpln 2 4 6 > > > Second file: > ------------ > > mtgoxusd > > > > Third File (the resulting one) : > -------------------------------- > > mtgoxeur 12 24 36 > mtgoxpln 2 4 6 > > > > Thanks to anyone that can help > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com --20cf307ca364ae31cf04d6cdf9ae Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Thu, Feb 28, 2013 at 2:14 PM, io <maroso@libero.it> wrote:
Hi,

i have to files.

First file is a csv file
Second file is a plain text file where each row has a value (text)

Read the second file so that you have a list of= each of its values

Read the first file line by line.=C2= =A0 Check if the value at the beginning of the line is in the list of value= s from the second file.=C2=A0 If not, print it to outfile.

You should look up split method on strings to split a string= separated by whitespace.

I want to be able to create a third file using data from the first file
excluding the values listed in the second file.

Example:

First file:
-----------

mtgoxeur =C2=A0 =C2=A0 =C2=A0 =C2=A012 =C2=A0 =C2=A0 =C2=A024 =C2=A0 =C2=A0= =C2=A036
mtgoxusd =C2=A0 =C2=A0 =C2=A0 =C2=A010 =C2=A0 =C2=A0 =C2=A012 =C2=A0 =C2=A0= =C2=A014
mtgoxpln =C2=A0 =C2=A0 =C2=A0 =C2=A02 =C2=A0 =C2=A0 =C2=A0 4 =C2=A0 =C2=A0 = =C2=A0 6


Second file:
------------

mtgoxusd



Third File (the resulting one) :
--------------------------------

mtgoxeur =C2=A0 =C2=A0 =C2=A0 =C2=A012 =C2=A0 =C2=A0 =C2=A024 =C2=A0 =C2=A0= =C2=A036
mtgoxpln =C2=A0 =C2=A0 =C2=A0 =C2=A02 =C2=A0 =C2=A0 =C2=A0 4 =C2=A0 =C2=A0 = =C2=A0 6



Thanks to anyone that can help


--
http://mail.python.org/mailman/listinfo/python-list



--
--20cf307ca364ae31cf04d6cdf9ae--