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


Groups > comp.lang.python > #56305

Re: How to streamingly read text file and display whenever updated text

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andipersti@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.028
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:text': 0.05; 'received:192.168.178': 0.07; 'rename': 0.07; 'subject:file': 0.07; 'subject:How': 0.10; 'python': 0.11; 'changes': 0.15; "'\\n')": 0.16; 'andreas': 0.16; 'bye,': 0.16; 'descriptor.': 0.16; 'received:192.168.178.20': 0.16; 'simulate': 0.16; 'subject: \n ': 0.16; 'url:file': 0.16; 'wrote:': 0.18; 'later': 0.20; 'seems': 0.21; 'example': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; 'file.': 0.24; 'script': 0.25; 'header:In-Reply- To:1': 0.27; 'thus': 0.29; "doesn't": 0.30; 'work.': 0.31; 'file': 0.32; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'next': 0.36; 'should': 0.36; 'growing': 0.38; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'short': 0.38; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'deleting': 0.60; 'new': 0.61; 'matter': 0.61; 'simple': 0.61; 'save': 0.62; 'email addr:gmail.com': 0.63; 'name': 0.63; 'temporary': 0.65; 'readers': 0.68; 'clicking': 0.73; 'demonstrates': 0.84; 'subject:read': 0.84; 'url:edit': 0.84; 'url:tech': 0.84; 'url:23': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=f5dc67BAxZ/Him2rGvVoL44/89p0+sdXvs5acbElT30=; b=ytve7vba66MKfM2dvP7ZvXRgjWXP0nuZiwshmU1NxSnPRZoaKkvtJDyz6SXfTinqay /e/U4WXeC9/y03Fww4PGfBoT77DPCxd3fFDDdRpkEerJn5HCa3tMQisuXWn6mcG9sYQN xVrocSGji3O9LGWY0UfDncoHhPSS8yhFduTdluq++EInioIeGRbJQAI0sWyTcwyFY8fx 4gacKm1SLv8MVinn6DvphP2Z2LHlXS6AWZaAKH+tRqug6lvifr9dPEn2PCdtSAyP7sDN QAr/zQobEylesRxRMhFFwoXzlBo5qOAJIx/TWrOU7SJW0eb1ZHjV5vk7GeTGK9eH0J4d fKsg==
X-Received by 10.204.61.195 with SMTP id u3mr798156bkh.43.1381139548464; Mon, 07 Oct 2013 02:52:28 -0700 (PDT)
Date Mon, 07 Oct 2013 11:52:25 +0200
From Andreas Perstinger <andipersti@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0
MIME-Version 1.0
To python-list@python.org
Subject Re: How to streamingly read text file and display whenever updated text
References <04ee91f9-1cbf-4364-bca3-da25aa4db45f@googlegroups.com> <mailman.739.1380970927.18130.python-list@python.org> <f0461031-fd7c-42ff-b88b-c77cffcdce76@googlegroups.com> <5250e1d6$0$29984$c3e8da3$5496439d@news.astraweb.com> <l2ref8$efd$1@ger.gmane.org> <CAPTjJmoZCGSzvskDri-ZBbHto4Bo9=dg_XmvouzPyc9LOBXhRw@mail.gmail.com> <l2rgjn$22h$1@ger.gmane.org> <CAPTjJmqvB9nk71yCVkdUisZPRk=Ouk7Es3QB53kBvtXGzxGYng@mail.gmail.com> <l2rhm9$90a$1@ger.gmane.org> <mailman.778.1381060337.18130.python-list@python.org> <65edfb89-52a7-4da3-85af-cc7c45601175@googlegroups.com>
In-Reply-To <65edfb89-52a7-4da3-85af-cc7c45601175@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
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 <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.805.1381139555.18130.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381139555 news.xs4all.nl 15883 [2001:888:2000:d::a6]:52958
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56305

Show key headers only | View raw


On 07.10.2013 03:54, galeomaga@gmail.com wrote:
> https://docs.google.com/file/d/0B2D69u2pweEvelh1T25ra19oZEU/edit?usp=sharing
>

For the readers who don't bother clicking on the link above: It's a 
short video where the OP demonstrates how her/his usage of tail doesn't 
work.

> no matter call tail directly in python or using the script of tail
> all failed
> it seems it can not read next line

In your video you use gedit to write some file and "tail -f <file>" to 
follow it. But "tail -f" will follow the file descriptor. Usually, 
editors like gedit won't save your changes to the original file but 
create a new temporary file and rename it later to the original file 
name after deleting the original one. Thus tail will follow an already 
deleted file.
See also this blog post:
http://tech.shantanugoel.com/2009/12/23/continuous-monitor-tail-fails.html

For your example you will have to use "tail -F <file>" which will follow 
the file name.

Alternatively you could write a simple script to simulate a continously 
growing file like

import time
for i in range(1000):
     with open("test.txt", "a") as f:
         f.write(str(i) + '\n')
     time.sleep(1)

which should work with "tail -f".

Bye, Andreas

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


Thread

How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-05 00:38 -0700
  Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-05 00:54 -0700
    Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-05 09:12 +0100
  Re: How to streamingly read text file and display whenever updated text "James Harris" <james.harris.1@gmail.com> - 2013-10-05 09:06 +0100
    Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-05 09:14 +0100
  Re: How to streamingly read text file and display whenever updated text Nobody <nobody@nowhere.com> - 2013-10-05 11:25 +0100
  Re: How to streamingly read text file and display whenever updated text Joost Molenaar <j.j.molenaar@gmail.com> - 2013-10-05 13:02 +0200
    Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-05 20:17 -0700
      Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 14:28 +1100
      Re: How to streamingly read text file and display whenever updated text Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-06 04:06 +0000
        Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-06 01:49 -0700
        Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 11:36 +0100
        Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 22:03 +1100
        Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 12:13 +0100
        Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 22:15 +1100
        Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-06 12:31 +0100
        Re: How to streamingly read text file and display whenever updated text Chris Angelico <rosuav@gmail.com> - 2013-10-06 22:44 +1100
          Re: How to streamingly read text file and display whenever updated text galeomaga@gmail.com - 2013-10-06 18:54 -0700
            Re: How to streamingly read text file and display whenever updated text Andreas Perstinger <andipersti@gmail.com> - 2013-10-07 11:52 +0200
  Re: How to streamingly read text file and display whenever updated text Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-05 12:08 +0100

csiph-web