Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:file': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '"can\'t': 0.16; "'w')": 0.16; 'csv': 0.16; 'format:': 0.16; 'help?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'subject:txt': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'module': 0.19; 'header:User-Agent:1': 0.23; 'code:': 0.26; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; 'txt': 0.31; 'file': 0.32; 'lists': 0.32; 'thanks!': 0.32; 'subject:from': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'subject:data': 0.36; 'next': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:x 10': 0.40; 'export': 0.74; 'ana': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Export data from python to a txt file Date: Fri, 29 Mar 2013 19:11:01 +0100 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Gmane-NNTP-Posting-Host: p508492c7.dip.t-dialin.net User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364580641 news.xs4all.nl 6904 [2001:888:2000:d::a6]:51366 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42264 Ana DionĂ­sio wrote: > I have this lists a=[1,3,5,6,10], b=[a,t,q,r,s] and I need to export it to > a txt file and I can't use csv. What do you mean by "can't use csv"? - You cannot get it to work with the csv module - You are not allowed to use csv by your instructor - Something else. > And I want the next format: > > a 1 3 5 6 10 > b a t q r s > > I already have this code: > > "f = open("test.txt", 'w') > f.write("a") > f.write("\n") > f.write("b") > f.write("\n") > > for i in xrange(len(a)): > LDFile.write("\t") > LDFile.write(str(a[i])) > LDFile.write("\t") > LDFile.write(str(b[i])) > > f.close()" > > But it doesn't have the format I want. Can you help? > > Thanks!