0

Hi..

I have a file with title output.dat.format of this file is as follows

0	0.00E+00	0.00E+00	-2.00E-02	9.48E+02
1	0.00E+00	0.00E+00	-1.80E-02	9.48E+02

yes,Thats right.without any comma between.(just tab space)

i need to create a file from this output.dat which has form similar to

0,9.48E+02
0,9.48E+02

i.e the first and last column separated by comma and no white space in the entire line...I tried to code this by creating dictionary...i am unable to get the required output

PS:the initial file 1.e output.dat has 10,000 line in a format mentioned above

Edited by kaskoraja: incoorect formating

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by kaskoraja
0

You have zero in your input at second column, not first one. Input has float but you have output with integer string value, is output value integral
You can split task in two, just read in the float numbers with with open ...as. And process with strip and split methods, print out the desired columns as test.

Edited by pyTony: n/a

0

I am extremely sorry...the final output file should be the following

0,9.48E+02
1,9.48E+02
1

So you can use this to give start (I leave out file i/o not to give all solution):

data = """0	0.00E+00	0.00E+00	-2.00E-02	9.48E+02
1	0.00E+00	0.00E+00	-1.80E-02	9.48E+02""".splitlines()
for d in data:
    line = d.strip().split()
    print line[0]+','+line[-1]
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.