Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!not-for-mail From: Michael Newsgroups: comp.lang.python Subject: Re: Python path and append Date: Tue, 26 Apr 2016 19:16:56 +0100 Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de sf+UBX4sZoOIz7YIxBIPOgqUYcJQ8VdCjaZ0Lqen4ZlA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.05; 'append': 0.07; "'w')": 0.09; 'lines:': 0.09; 'file,': 0.15; "'r')": 0.16; 'f.read()': 0.16; 'helps!': 0.16; 'need:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:name:python- list@python.org': 0.20; 'if,': 0.29; 'code:': 0.29; 'code': 0.30; 'another': 0.32; 'file': 0.34; 'text': 0.35; 'lines': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'end': 0.39; 'to:addr:python.org': 0.40; 'space': 0.40; 'hope': 0.61; 'entire': 0.61; 'wish': 0.71; 'asterisk': 0.84; 'email addr:hotmail.com': 0.89; 'hand,': 0.97 X-TMN: [593pVeoxWgv+CW+mXShr32kLHnWUXf4W] X-Originating-Email: [bigbadmick2000@hotmail.com] Importance: Normal X-OriginalArrivalTime: 26 Apr 2016 18:16:56.0397 (UTC) FILETIME=[D10C6FD0:01D19FE7] X-Mailman-Approved-At: Tue, 26 Apr 2016 14:18:12 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 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: Xref: csiph.com comp.lang.python:107681 If you want to read an entire file=2C append a space and asterisk and write= it to another file=2C this is the code you need: infile =3D open('win.txt'=2C 'r') text =3D f.read() infile.close() text +=3D " *" outfile =3D open('outfile.txt'=2C 'w') outfile.write(text) outfile.close() If=2C on the other hand=2C you wish to read a file and append a space and a= sterisk TO THE END OF EVERY LINE=2C you require the following code: infile =3D open('win.txt'=2C 'r') lines =3D infile.readlines() infile.close() outfile =3D open('outfile.txt'=2C 'w') for line in lines: line =3D line.strip() + " *\n" outfile.write(line) outfile.close() Hope that helps! BigBadMick bigbadmick2000@hotmail.com =