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


Groups > comp.lang.python > #40161

Re: Read csv file and create a new file

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 <joel.goldstick@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; '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 <joel.goldstick@gmail.com>
To io <maroso@libero.it>
Content-Type multipart/alternative; boundary=20cf307ca364ae31cf04d6cdf9ae
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.2668.1362080055.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

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.  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

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


Thread

Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 19:14 +0000
  Re: Read csv file and create a new file Neil Cerutti <neilc@norwich.edu> - 2013-02-28 19:32 +0000
  Re: Read csv file and create a new file Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-28 14:34 -0500
  Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 14:35 -0500
  Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 19:51 +0000
    Re: Read csv file and create a new file Neil Cerutti <neilc@norwich.edu> - 2013-02-28 20:11 +0000
      Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:23 +0000
        Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:46 +0000
          Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:51 +0000
          Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 16:23 -0500
            Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 22:05 +0000
              Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 19:13 -0500
  Re: Read csv file and create a new file Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-28 21:04 -0500
    Re: Read csv file and create a new file io <maroso@libero.it> - 2013-03-04 19:04 +0000
      Re: Read csv file and create a new file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-04 23:58 +0000

csiph-web