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


Groups > comp.lang.python > #87172

Re: Append a file

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jven2eri@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'skip:u 30': 0.07; 'subject:file': 0.07; 'f.close()': 0.09; 'line:': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '"w")': 0.16; ':-).': 0.16; 'easier.': 0.16; 'i\xe2\x80\x99m': 0.16; 'ought': 0.16; 'python3.': 0.16; 'two.': 0.16; 'url:)': 0.16; 'wrote:': 0.18; 'module': 0.19; 'seems': 0.21; 'command': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'tutorials': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'lines': 0.31; 'requests': 0.31; '>>>>': 0.31; 'file': 0.32; 'fri,': 0.33; 'mac': 0.33; 'received:google.com': 0.35; 'done': 0.36; 'url:org': 0.36; 'two': 0.37; 'starting': 0.37; 'message-id:@gmail.com': 0.38; 'thank': 0.38; 'jason': 0.38; 'pm,': 0.38; 'skip:_ 30': 0.39; 'skip:u 10': 0.60; 'header:Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'kind': 0.63; 'url:user': 0.65; 'to:addr:gmail.com': 0.65; 'sample': 0.67; 'mar': 0.68; 'response.': 0.68; 'results': 0.69; '2015': 0.84; 'url:latest': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:mime-version:subject:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=o0m/Zb9bk/+ZScP0MUci6pk/b0QXx1dilw/dj7fSvvQ=; b=Bt/IgKdpHej1jpeDkVF4I9KfAvTBNgkDS08wcQg7mBW27jTbv3/lL10u7uwEy8OpNJ sAcpRK64obg7w92pDV5wfE4hYB9NJMNHTgL6Aif91pS7juvQqhlLPVcegdaC7W26tJFa 4rLTyfpDbRAvi4XwuVIyKM4urjTICKMeQNN90GFXK0XYRwoDvbWUWM0xxh4LeCq36n9b YyvNJ42T9rqigPJlzSp3hrRRS/lNj0ZEfVnojUNjsvLlyPlgFip2zrCj+lSO7pT8lK99 PuBj4+QD2qJ1CM3oUtUt5pkqrEuv5FUQRddG3ltHwghatHx9pzIJ77Qzp4QI5ASuBYOH fEpQ==
X-Received by 10.66.241.71 with SMTP id wg7mr48667254pac.81.1425877871441; Sun, 08 Mar 2015 22:11:11 -0700 (PDT)
From Jason Venneri <jven2eri@gmail.com>
X-Google-Original-From Jason Venneri <jv92109@gmail.com>
Content-Type text/plain; charset=utf-8
Mime-Version 1.0 (Mac OS X Mail 8.2 \(2070.6\))
Subject Re: Append a file
In-Reply-To <CANy1k1itseSsjGTjuMSqHOmC-Y+Voenp1EEyoyAs9GR5payBxA@mail.gmail.com>
Date Sun, 8 Mar 2015 22:11:07 -0700
Cc python-list <python-list@python.org>
Content-Transfer-Encoding quoted-printable
References <adcd6103-cba5-4eda-9af6-e6ba95789159@googlegroups.com> <CANy1k1itseSsjGTjuMSqHOmC-Y+Voenp1EEyoyAs9GR5payBxA@mail.gmail.com>
To Jason Friedman <jsf80238@gmail.com>
X-Mailer Apple Mail (2.2070.6)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.185.1425877880.21433.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1425877880 news.xs4all.nl 2843 [2001:888:2000:d::a6]:34533
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87172

Show key headers only | View raw


Jason;

Thank you for your response.  I’m just starting out with Python and the tutorials I have done are on 2.7.9.  I will looking on to python3.  It is preloaded on Mac :-).

Jason
_______________________________


jv92109@gmail.com

619-227-0927

> On Mar 6, 2015, at 9:37 PM, Jason Friedman <jsf80238@gmail.com> wrote:
> 
> On Fri, Mar 6, 2015 at 2:55 PM, Jason Venneri <jv92109@gmail.com> wrote:
>> Hello, I'm using the urllib.urlretrieve command to retrieve a couple of lines of data.  I want to combine the two results into one file not two.
>> 
>> Any suggestions?
>> 
>> Sample
>> urllib.urlretrieve('http://www.airplanes.com/data/boeing1.html','B747A.txt')
>> urllib.urlretrieve('http://www.airplanes.com/data/boeing2.html','B747B.txt')
>> 
>> I would like one file say B747C that contains the data from B747A and B747B in a file named B747C
> 
>>>> f = open("B747C.txt", "w")
>>>> look_for = "Aircraft,"
>>>> for line in open("B747A.txt"):
> ...     if look_for in line:
> ...         f.write(line)
> ...
>>>> for line in open("B747B.txt"):
> ...     if look_for in line:
> ...         f.write(line)
> ...
>>>> f.close()
> 
> Seems like you are using Python 2, you ought to consider Python 3.
> 
> The requests module
> (http://docs.python-requests.org/en/latest/user/install/) makes this
> kind of work easier.

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


Thread

Append a file Jason Venneri <jv92109@gmail.com> - 2015-03-06 13:55 -0800
  Re: Append a file sohcahtoa82@gmail.com - 2015-03-06 14:05 -0800
  Re: Append a file Jason Friedman <jsf80238@gmail.com> - 2015-03-06 22:37 -0700
  Re: Append a file Jason Venneri <jven2eri@gmail.com> - 2015-03-08 22:11 -0700

csiph-web