Xavier Morel <[EMAIL PROTECTED]> wrote:
> Fredrik Lundh wrote:
> > did you read the string chapter in the tutorial ?
> >
> > http://docs.python.org/tut/node5.html#SECTION00512
> >
> > around the middle of that chapter, there's a section on slicing:
> >
> > "substrings can be
Fredrik Lundh wrote:
> did you read the string chapter in the tutorial ?
>
> http://docs.python.org/tut/node5.html#SECTION00512
>
> around the middle of that chapter, there's a section on slicing:
>
> "substrings can be specified with the slice notation: two indices
> sep
Hi,
you have plenty of good responses. I thought I would add one more:
def data_iter(file_name):
data = file(file_name)
while True:
value = data.read(3)
if not value:
break
yield value
data.close()
With the above, you can grab the entire data set
Sure. There's probably a thousand ways to do this.
--
http://mail.python.org/mailman/listinfo/python-list
nuttydevil wrote:
> Hey everyone! I'm hoping someone will be able to help me, cause I
> haven't had success searching on the web so far... I have large chunks
> of text ( all in a long string) that are currently all in separate
> notebook files. I want to use python to read these strings of text,
>
If you have already read the string into memory and want a convenient
way to loop through it 3 characters at a time, check out the "batch" recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303279
It uses itertools to make an iterator over the string, returning 3
characters at a ti
"nuttydevil" <[EMAIL PROTECTED]> wrote:
> Hey everyone! I'm hoping someone will be able to help me, cause I
> haven't had success searching on the web so far... I have large chunks
> of text ( all in a long string) that are currently all in separate
> notebook files. I want to use python to read t
[EMAIL PROTECTED] wrote:
> I think this is what you want:
>
> file = open(r'c:/test.txt','r')
>
> c = file.read(3)
> while c:
> print c
> c = file.read(3)
>
> file.close();
Or:
def read3():
return file.read(3)
for chars in iter(read3, ''):
... do something
I think this is what you want:
file = open(r'c:/test.txt','r')
c = file.read(3)
while c:
print c
c = file.read(3)
file.close();
--
http://mail.python.org/mailman/listinfo/python-list
In article <[EMAIL PROTECTED]>,
"nuttydevil" <[EMAIL PROTECTED]> wrote:
> Hey everyone! I'm hoping someone will be able to help me, cause I
> haven't had success searching on the web so far... I have large chunks
> of text ( all in a long string) that are currently all in separate
> notebook file
nuttydevil wrote:
> Hey everyone! I'm hoping someone will be able to help me, cause I
> haven't had success searching on the web so far... I have large chunks
> of text ( all in a long string) that are currently all in separate
> notebook files. I want to use python to read these strings of text,
>
nuttydevil <[EMAIL PROTECTED]> wrote:
> Hey everyone! I'm hoping someone will be able to help me, cause I
> haven't had success searching on the web so far... I have large chunks
> of text ( all in a long string) that are currently all in separate
> notebook files. I want to use python to read the
Hey everyone! I'm hoping someone will be able to help me, cause I
haven't had success searching on the web so far... I have large chunks
of text ( all in a long string) that are currently all in separate
notebook files. I want to use python to read these strings of text,
THREE CHARACTERS AT A TIME.
13 matches
Mail list logo