Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.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:Python': 0.06; '(b)': 0.07; 'column': 0.07; 'subject:file': 0.07; 'string': 0.09; 'f.close()': 0.09; 'repeated': 0.09; '.txt': 0.16; 'columns': 0.16; 'expecting': 0.16; 'i.e': 0.16; 'subject:writing': 0.16; 'trying': 0.19; 'written': 0.21; 'input': 0.22; 'example': 0.22; 'import': 0.22; 'to:name:python-list@python.org': 0.22; '(a)': 0.24; 'questions:': 0.24; 'file.': 0.24; 'subject: : ': 0.26; '(c)': 0.29; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'file': 0.32; 'open': 0.33; 'skip:# 10': 0.33; 'received:google.com': 0.35; 'add': 0.35; 'easiest': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'provide': 0.64; 'saturday': 0.68; '\xc2\xa0\xc2\xa0': 0.74; 'day': 0.76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=AnFMIaOhsZLAVtHdE04cAluFEYTKFoBeBbRugqZ0gfY=; b=xAMjT1LQUDH3N2DSAXFIKMfgDG8H1wRLiW51XSdBOK5mfRSeXakSTpGvbSHCQTeki4 4ImNQvyup+OgYnAx4A09gnQztLb3Mn2PLVrgf2Zksuci/lLz6IutHSEcH5A98zdF+O3x gqFLzCapM22M4lkpRKTlpFTMKmNt/9TQLjJ5HYBH5NvmE1Kmdp+PSq45Iig1Ij1MRiS/ hAzqZjvfYFcM+uAjbPlINr4GCQscNOoL7lOPUahZKgNdwQ13UzENSDXcwOVefkOwpN5/ VJKgoTehTNw9IsA2Zpu+kheMU3BWcX6KD7svbZAYWgKeMQ/rAoaOx7dHQGZc3l0hPKvh VHjg== MIME-Version: 1.0 X-Received: by 10.112.73.66 with SMTP id j2mr27528258lbv.44.1420902849632; Sat, 10 Jan 2015 07:14:09 -0800 (PST) Date: Sat, 10 Jan 2015 20:44:09 +0530 Subject: Python : writing to a file From: Ganesh Pal To: "python-list@python.org" Content-Type: multipart/alternative; boundary=001a11c344b49cdec6050c4db9cc 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: 72 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420902853 news.xs4all.nl 2899 [2001:888:2000:d::a6]:60211 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83502 --001a11c344b49cdec6050c4db9cc Content-Type: text/plain; charset=UTF-8 Please provide you input on the below questions: (a) I was expecting the string i.e day of week , example Saturday to be written in the file. what Iam I missing in the below program ? Program: #!/usr/bin/python import time f = open ('test_2.txt','w+b') DAY = time.strftime("%A") f.write(DAY) f.close() Throttling-1# cat test_2.txt (b) Iam trying to generate a file in the below format , cluster1# cat test_2.txt Saturday 0:05 0:10 Saturday 0:10 0:20 Saturday 0:20 0:30 Saturday 0:40 0:50 Saturday 0:60 0:70 (a) what is the easiest way to generate the above file fprmat ? (b) how will I take care that the below format is repeated in the .txt file ( i.e column and row spacing) DAY OF THE WEEK [SPACE] START TIME [ SPACE] ENDTIME{SPACE] (c) how do I add START TIME [ SPACE] ENDTIME{SPACE] columns Regards, Ganesh --001a11c344b49cdec6050c4db9cc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Please provide you input on the below questions:


(a) I was expecting =C2=A0the string i.= e day of week , example Saturday to be written in the file. what Iam I miss= ing in the below program =C2=A0?

Program:

#!/usr/bin/python

import time=
f =3D open ('test_2.txt','w+b')
DAY = =3D time.strftime("%A")
f.write(DAY)
f.close(= )

Throttling-1# cat test_2.txt

(b) Iam trying to generate a file in the below format ,
cluster1# cat test_2.txt

Satu= rday 0:05 0:10
Saturday 0:10 0:20
Saturday 0:20 0:30
Saturday 0:40 0:50
Saturday 0:60 0:70
(a) what is the easiest way to generate the above file fpr= mat ?

(b) how will I take care that the belo= w format is repeated in the .txt file=C2=A0
=C2=A0 ( i.e column a= nd row spacing)
=C2=A0
=C2=A0 =C2=A0 DAY OF THE WEEK = =C2=A0[SPACE] START TIME [ SPACE] ENDTIME{SPACE]

<= br>
(c) how do I =C2=A0add START TIME [ SPACE] ENDTIME{SPACE] col= umns=C2=A0
=C2=A0 =C2=A0=C2=A0


Regards,
Ganesh


--001a11c344b49cdec6050c4db9cc--