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


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

Recommended Answers

All 4 Replies

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.

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


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]

That solved my problem...thanks a lot!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.