Reputation: 4744
Writing floats to a CSV writes some of them like this: 2.0628800997782577e-05
c = csv.writer(open(file, "wb"))
c.writerow([var1, var2])
What I've tried:
This makes it difficult to process the output in excel afterwards as it's recognized as text and not a number. How can I print it in non-scientific, decimal notation?
Upvotes: 2
Views: 3463
Reputation: 39950
Use string formatting:
c.writerow(['{:f}'.format(var) for var in (var1, var2)]
Upvotes: 4