Something like this does the job, I think.
data = '''X, Y, Z
0.000234E+04, 0.000244E+03, 0.000234E+04
0.000244E+03, 0.000234E+04, 0.000238E+05
0.000238E+05, 0.000244E+03, 0.000234E+04'''
numbers = data.splitlines()
print numbers.pop(0)
print '\n'.join(', '.join(str(float(value))
for value in numberline.split(',')
)
for numberline in numbers)
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
p=open(r'C:\file.txt', 'r')
numbers = p.splitlines()
print numbers.pop(0)
print '\n'.join(', '.join(str(float(value))
for value in numberline.split(' , ')
)
for numberline in numbers)
I thought to leave something for you to do also, but OK, try this:
with open('file.txt') as p:
print p.next(),
print '\n'.join(
', '.join(str(float(value))
for numberline in numbers.rstrip().split(' \n') # take out '\n' by rstrip()
for value in numberline.split(','))
for numbers in p)
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852