One easy way out is to write
udskrift.write((" %.5E , %.5E\n" % (entry[2], entry[3])).replace('E+', 'E'))
but that does not seem pythonic.
Question
So I am writing the columns of an array to a file and the file is to be used by a program that is space sensitive, so it has to be exactly the right way like this:
*DEFINE_CURVE_TRIM
$ TCID TCTYPE TFLG TDIR TCTOL TOLN/IGB NSEED
1111 1 -1 0 0.001
7.50000E01 , 0.00000E00
7.49906E01 , 1.18995E00
7.49622E01 , 2.37960E00
I am working with some floats with alot of decimals, so I am rounding them to have the same number of decimals, but python notation is E+01 and it has to be E01
udskrift = open('DEFINE_CURVE_TRIM_FULL','w')
udskrift.write('*DEFINE_CURVE_TRIM\n$ TCID TCTYPE TFLG TDIR TCTOL TOLN/IGB NSEED\n 1111 1 -1 0 0.001\n')
for entry in polar_koordinator:
udskrift.write(" %.5E , %.5E\n" % (entry[2], entry[3]))
output is
*DEFINE_CURVE_TRIM
$ TCID TCTYPE TFLG TDIR TCTOL TOLN/IGB NSEED
1111 1 -1 0 0.001
8.00976E+01 , 0.00000E+00
8.01050E+01 , 1.25839E+00
So any pointers on how to remove the '+' so it becomes E01? I would hate to have to reopen the file and remove them
Solution
One easy way out is to write
udskrift.write((" %.5E , %.5E\n" % (entry[2], entry[3])).replace('E+', 'E'))
but that does not seem pythonic.