Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: String Attribute

27 views
Skip to first unread message

Terry Reedy

unread,
Jul 29, 2015, 1:50:30 PM7/29/15
to pytho...@python.org
On 7/28/2015 7:38 PM, ltc.h...@gmail.com wrote:

> What is the source of the syntax error to the String Attribute?
>
> Go to the following URL links and view a copy of the raw data file code
> and sample data:
>
> 1.) http://tinyurl.com/p2xxxhl
> 2.) http://tinyurl.com/nclg6pq

If you want help here, reduce your code and input to the minimum needed,
put the input in the code as a string, and if you still do not see the
problem, post here, along with the traceback.

> Here is the desired output:
>
> stephen....@uct.ac.za <mailto:stephen....@uct.ac.za>
> lo...@media.berkeley.edu <mailto:lo...@media.berkeley.edu>

--
Terry Jan Reedy

John Strick

unread,
Jul 29, 2015, 4:46:30 PM7/29/15
to
fname = raw_input("Enter file name: ")
if len(fname) < 1 :
fname = "mbox-short.txt"
for line in fname:
line = line.strip()
if not line.startwith('From '):
continue
line = line.split()
count = count + 1


You need to actually open the file. (Look up how to do that) The first 'for' loop is looping through the file NAME, not the file OBJECT. Also, line.startwith() should be line.startswith().

--john
0 new messages