Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70539
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news.astraweb.com!border2.a.newsrouter.astraweb.com!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dhananjay.c.joshi@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'column': 0.07; 'reason,': 0.07; 'subject:file': 0.07; '#print': 0.09; '[];': 0.09; 'def': 0.12; 'suggest': 0.14; 'files:': 0.16; 'trying': 0.19; 'advance.': 0.19; 'everyone,': 0.19; 'print': 0.22; 'error': 0.23; 'skip:e 30': 0.24; 'script': 0.25; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'anyone': 0.31; 'file': 0.32; 'skip:# 10': 0.33; 'could': 0.34; 'message.': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'skip:o 20': 0.38; 'follows:': 0.38; 'to:addr :python-list': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; '2nd': 0.60; 'skip:\xc2 10': 0.60; 'skip:o 30': 0.61; '8bit%:92': 0.71; '8bit%:100': 0.72; 'thanking': 0.84 |
| 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=poWEviPRjiDoqKoX62yGVnJy0Sp2ABGkKblt7rCcAZ4=; b=L7pbeavw9Z82qmiJ+NiGJkkOGpWBhDkuIz4gZWxNsiUpHrLygWc0NPi3B52OV2inB3 R3Yn8NYkHIpnH5tmRt7nDvXXCfdW3b5pdukQjOZTYxQSb/gdTWl/ghnpp2GSEaEVJ0My /LjjOOdZKYTDh/EIsuHMexrq9OD0b2rnpz9dXiwF6hrGoeL59jcPRQurO2o56muvIj8z ym7z8Sjo4hdgFFBW2m8WIa51v/CvfOAlL68sRYkAOGWrzC9j+73Q20XyKZWAWvjbMhmx nSFJYQs9yvscweNFzLoxj91ehFegsBx3R5/J4JWgXd664s34JIeqn1uR6cKbnBsgBQ33 Ijxw== |
| MIME-Version | 1.0 |
| X-Received | by 10.182.81.39 with SMTP id w7mr6354886obx.56.1398239631361; Wed, 23 Apr 2014 00:53:51 -0700 (PDT) |
| Date | Wed, 23 Apr 2014 15:53:51 +0800 |
| Subject | how to write list in a file |
| From | Dhananjay <dhananjay.c.joshi@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=047d7b2e437e89cb3804f7b1084f |
| 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.9461.1398239639.18130.python-list@python.org> (permalink) |
| Lines | 100 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1398239639 news.xs4all.nl 2842 [2001:888:2000:d::a6]:37521 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:70539 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hello everyone,
I am trying hard to write a list to a file as follows:
def average_ELECT(pwd):
os.chdir(pwd)
files = filter(os.path.isfile, os.listdir('./'))
folders = filter(os.path.isdir, os.listdir('./'))
eelec = 0.0; evdw = 0.0; EELEC = []; elecutoff = [];
g = Gnuplot.Gnuplot()
for f1 in files:
# if f1[21:23]=='12':
if f1[27:29]==sys.argv[1]: # vdw cutoff remains constant; see 2nd
column of output
fl1 = open(f1,'r').readlines()
# print len(fl1)
for i in range(1, len(fl1)):
fl1[i]=fl1[i].split()
eelec = eelec + float(fl1[i][1])
evdw = evdw + float(fl1[i][2])
#print fl1[i][1], fl1[i][2]
avg_eelec = eelec/40
avg_evdw = evdw/40
# print eelec, evdw
# print f1[21:23], f1[27:29], avg_eelec, avg_evdw
print f1[21:23], f1[27:29], avg_eelec
# EELEC.append(avg_eelec); elecutoff.append(float(f1[21:23]))
eelec=0.0; evde=0.0;
a = f1[21:23]+' '+f1[27:29]+' '+str(avg_eelec)
EELEC.append(a)
print sorted(EELEC)
with open('EElect_elec12-40_vdwxxx.dat','w') as wr:
for i in EELEC:
print i
wr.write("%s\n" % i)
wr.close()
The script is printing "print sorted(EELEC)" as well as "print f1[21:23],
f1[27:29], avg_eelec" very well.
However, for some reason, I neither see any file (expected to see
EElect_elec12-40_vdwxxx.dat as per the script) generated nor any error
message.
Could anyone suggest me correction here.
Thanking you in advance.
-- DJ
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
how to write list in a file Dhananjay <dhananjay.c.joshi@gmail.com> - 2014-04-23 15:53 +0800
csiph-web