Hi all,
thanks for all your answers. Is see that there are - as ususal - several
ways to accomplish this. I decided to go for the way Frederik suggested,
because it looked as the most straight forward method for that kind
of data.
Thanks again,
./Tom
--
http://mail.python.org/mailman/listinfo/py
On Tue, 29 Nov 2005 17:40:08 GMT, Thomas Liesner <[EMAIL PROTECTED]> wrote:
[...]
>This is the codesnippet i am using:
Sorry, I made no comment on your actual code. Some follows.
>
>#!/usr/bin/python
>
>import string
I'm not seeing the need for importing string
>inp = open("xyplan.nobreaks","r")
On Tue, 29 Nov 2005 17:40:08 GMT, Thomas Liesner <[EMAIL PROTECTED]> wrote:
>Hello all,
>
>i am having some hard time to format the output of my small script. I am
>opening a file which containes just a very long string of hexdata
>seperated by spaces. Using split() i can split this string into si
Thomas Liesner wrote:
> ... i want to print always three of them in a single line and
> after that a linebreak.
How about:
def emit(aFile):
for line in aFile:
for word in line.split():
yield word
f = open('xyplan.nobreaks', 'r')
gen = iter(
Thomas Liesner wrote:
> Hello all,
>
> i am having some hard time to format the output of my small script. I am
> opening a file which containes just a very long string of hexdata
> seperated by spaces. Using split() i can split this string into single
> words and print them on stdout. So far so g
>>> a = [str(i) for i in range(0,17)]
>>> for i in range(0,len(a),3):
... print " ".join(a[i:i+3])
...
0 1 2
3 4 5
6 7 8
9 10 11
12 13 14
15 16
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 29, Fredrik Lundh wrote:
> inp = open("xyplan.nobreaks","r")
> data = inp.read()
>
> import textwrap
> for line in textwrap.wrap(data, 15):
> print line
Right -- if the data is that regular then every 15th item is the
split-point. A variation on this theme then is:
for i in range
Thomas Liesner wrote:
> i am having some hard time to format the output of my small script. I am
> opening a file which containes just a very long string of hexdata
> seperated by spaces. Using split() i can split this string into single
> words and print them on stdout. So far so good. But i want
You can try something like:
#!/usr/bin/python
import sys
inp = open("xyplan.nobreaks")
data = [ i.strip() for i in inp if i ]
while data:
print ' '.join(data[0:3])
del data[0:3]
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 29 Nov 2005 17:40:08 GMT in comp.lang.python, Thomas Liesner
<[EMAIL PROTECTED]> wrote:
[...]>
>So instead of:
>
>3905
>3009
>
[...]
>
>i'd like to have:
>
>3905 3009
[...]
>
>This is the codesnippet i am using:
>
>#!/usr/bin/python
>
>import string
>inp = open("xyplan.nobreaks","r
Thomas Liesner schrieb:
> [...]
> i am having some hard time to format the output of my small script. I am
> opening a file which containes just a very long string of hexdata
> seperated by spaces. Using split() i can split this string into single
> words and print them on stdout. So far so good. B
Hello all,
i am having some hard time to format the output of my small script. I am
opening a file which containes just a very long string of hexdata
seperated by spaces. Using split() i can split this string into single
words and print them on stdout. So far so good. But i want to print always
th
12 matches
Mail list logo