Re: [Tutor] File reading-(encoding problems)

2015-12-23 Thread Ben Finney
Ratheesh kumar writes: > Here is my code..try: > data=open('info.txt') […] Please be sure to present the code as distinct lines. You have posted it as plain text (good), the indentation is preserved (good). The problem here is that your commentary is mingled with the program code, so that

[Tutor] File reading-(encoding problems)

2015-12-23 Thread Ratheesh kumar
Here is my code..try: data=open('info.txt') for each_line in data: try: (role,line_spoken)=each_line.split(':',1) print(role,end='') print(' said: ',end='') print(line_spoken,end='') except ValueError: print(each_li

Re: [Tutor] File reading

2014-06-18 Thread Danny Yoo
Hi Uma, In your case, I'd look at the file as a sequence of "tokens" and look at this as a tokenization problem I think we'll see some kind of _identifier_, followed by _whitespace_, followed by a _string_. All these three tokens will repeat, until we hit the end of the the file. More formally

Re: [Tutor] File reading

2014-06-18 Thread Umamaheshwar Rao
i agree. i expect the output be "all the best" "all the best 2 next line\n check this" On Wed, Jun 18, 2014 at 6:24 PM, Danny Yoo wrote: > On Wed, Jun 18, 2014 at 6:08 PM, Umamaheshwar Rao > wrote: > > Hi Experts, > > > > I have a file with below format > > > > > Can you describe the format

Re: [Tutor] File reading

2014-06-18 Thread Danny Yoo
On Wed, Jun 18, 2014 at 6:08 PM, Umamaheshwar Rao wrote: > Hi Experts, > > I have a file with below format > Can you describe the format a little more precisely? You're giving examples, which is wonderful. But the examples are missing something. What's the output you want to get here? Imagi

[Tutor] File reading

2014-06-18 Thread Umamaheshwar Rao
Hi Experts, I have a file with below format this is first file operation x-1 "all the best" x-2 "all the best 2 next line check this" x-3 "last line" i need extract the lines starting with x-1 and x-2, can some throw some light on how to do? Thanks, Uma