l***@gmail.com
2015-07-29 21:55:34 UTC
Hi Everyone:
I have a second and unrelated question:
I tried to work backward to see if there is a logic error associated with a variable is being skipped over:
#top of code, initialize variable
output_list = ["default"]
#rest of code
If you get at the end
print output_list
['default']
Raw Data File:
count = 0
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
for line in fname:
line = line.strip()
if not line.startswith('From '): continue
line = line.split()
count = count + 1
print len(line)
fh = open(fname)
print "There were", count, "lines in the file with From as the first word"
Sample data file at http://www.pythonlearn.com/code/mbox-short.txt
Desired Output:
***@uct.ac.za
***@media.berkeley.edu
***@umich.edu
***@iupui.edu
***@umich.edu
***@iupui.edu
Thanks,
Hal
Sent from Surface
From: Phu Sam
Sent: Wednesday, July 29, 2015 1:06 PM
To: Ltc Hotspot
_______________________________________________
Baypiggies mailing list
***@python.org
To change your subscription options or unsubscribe:
https://mail.python.org/mailman/listinfo/baypiggies
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription opt
I have a second and unrelated question:
I tried to work backward to see if there is a logic error associated with a variable is being skipped over:
#top of code, initialize variable
output_list = ["default"]
#rest of code
If you get at the end
print output_list
['default']
Raw Data File:
count = 0
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
for line in fname:
line = line.strip()
if not line.startswith('From '): continue
line = line.split()
count = count + 1
print len(line)
fh = open(fname)
print "There were", count, "lines in the file with From as the first word"
Sample data file at http://www.pythonlearn.com/code/mbox-short.txt
Desired Output:
***@uct.ac.za
***@media.berkeley.edu
***@umich.edu
***@iupui.edu
***@umich.edu
***@iupui.edu
Thanks,
Hal
Sent from Surface
From: Phu Sam
Sent: Wednesday, July 29, 2015 1:06 PM
To: Ltc Hotspot
_______________________________________________
Baypiggies mailing list
***@python.org
To change your subscription options or unsubscribe:
https://mail.python.org/mailman/listinfo/baypiggies
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription opt