Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joel Goldstick Newsgroups: comp.lang.python Subject: Re: Appending an asterisk to the end of each line Date: Tue, 5 Jul 2016 18:27:25 -0400 Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de hQbcN93VQc0FetFaXfiHywkFb/u5ZoXWbf9SSaxRqEZg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'cc:addr:python-list': 0.09; "'w')": 0.09; 'url:blog': 0.10; "'r')": 0.16; '2016': 0.16; 'empty.': 0.16; 'file?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'creates': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'posted': 0.21; 'tried': 0.24; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'subject:end': 0.29; 'url:mailman': 0.30; 'folder': 0.30; 'run': 0.33; 'url:python': 0.33; 'url:listinfo': 0.34; 'tue,': 0.34; 'file': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'text': 0.35; 'but': 0.36; 'url:org': 0.36; 'lines': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'several': 0.38; 'skip:o 20': 0.38; 'subject:the': 0.39; 'url:mail': 0.40; 'ago.': 0.61; 'reuse': 0.66; 'url:info': 0.71; 'jul': 0.72; 'seymore4head': 0.84; 'subject:Appending': 0.84; 'to:none': 0.91; 'joel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc; bh=9aqxaMbpj/teI7gG5vwBL9RqbCrcUZiquNy78Hg3Clg=; b=KdicTrbmpPUaNdxvC3RWKgg01s1NnjDhusjLF4MJWxQM+7Gs3GtFdNAKFOG+UbxDJu /uxLZCL+aAD60rTiWZvQmrWOr3ajvKrgA8uiO1FFfjU4Pfof21/p0PDzr4qkvo0qLpwX noyxijeGUcKBTeV/MfNx0HeuwjnWBYlxGIuIPVluEtlJ01KiJe4Lrq9YCtjGa0cLyF88 2slns8vLQhj7s62UQkN/g4q47EmWN+S0vXMUEQ5EIpk9dTp8r2/QeEQdrzYADhP7aGz1 7We9+cKHkJ/6zB8DD+sbiTqKNvgu58835Olvf+5o/jD9ewNHwiQG7fgkY5M2M1aAeqgR mwIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc; bh=9aqxaMbpj/teI7gG5vwBL9RqbCrcUZiquNy78Hg3Clg=; b=NJLOUpKuDngO/9KCOEqXl5SMRzT9t4KTwDMmtX6N9g4PG4KC1lfSYYip25wOv3DWIO OliRrXkxZkyAWOMUzTphHjcGkAxGMMMWKl1gKiISvMw5ZWoZC9XvbL6KHG6vw4E5S1WQ j/feFHAT/F5UFs5ZzRmYAtJtFxU7bLkK3/SsqEY3ADSmC55Rl5STyUcUtgVWDy8TlbIl bWI3K4W3g2m/mtuChLyb6m8bhGgVclAQfhkxadAh0I45vOmrB+fo22OqiOStTRL6VEkt CXcxhuz/klYtSqYHCURcjh0V+yJ8ytJlQJ/Azm5LEPL2S2xAsXil7xTMMKWS5b94Tv8U Wjdw== X-Gm-Message-State: ALyK8tKUFlw1SIJqRFfnEhrGxIWhEZ0hBPEp4Zu21EFrILknZ9tElUxWkSzr8MU08G3/h0Mvz7h6DC977ky22Q== X-Received: by 10.157.9.248 with SMTP id 53mr1846316otz.35.1467757646423; Tue, 05 Jul 2016 15:27:26 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:111145 On Tue, Jul 5, 2016 at 6:05 PM, Seymore4Head wrote: > import os > > f_in = open('win.txt', 'r') > f_out = open('win_new.txt', 'w') > > for line in f_in.read().splitlines(): > f_out.write(line + " *\n") > > f_in.close() > f_out.close() > > os.rename('win.txt', 'win_old.txt') > os.rename('win_new.txt', 'win.txt') > > > I just tried to reuse this program that was posted several months ago. > I am using a text flie that is about 200 lines long and have named it > win.txt. The file it creates when I run the program is win_new.txt > but it's empty. > > > -- > https://mail.python.org/mailman/listinfo/python-list Are you running program in same folder as text file? -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays