When I read a record, no mater what switch I use in the Open, large numbers are converted to scientific notation. These numbers are for mailing, so it's a combination of a zip, plus4, delivery point, etc. I need to keep the number intact Is there some way to read the record and keep those numbers from converting?

7 Years
Discussion Span
Last Post by Tommymac501

It's a csv file, using open("file.csv"), 'r').. I've tried 'rt', 'rb'.. I tried both with and without Import CSV, in every case they convert. Are you saying to declare a variable to receive it as a string first like S = '' ?

f = open("v20100515.csv",'rt')

L = ''
L = f.readline()
L = f.readline()
print (str((L)))

Still produces; .... 5/15/2010 0:55,,1,5000,1500,6.84E+19,A ......

Edited by Tommymac501: n/a


That indicates that the .csv file has it in scientific notation. No string-number conversions exist there.

also this code L = '' is useless. L is not "declared" as a string. Python doesn't do that. If L is first a string, it doesn't mean it will always be a string. That's the power of dynamic languages.

Edited by jcao219: n/a


I know that python is dynamic and L='' doesn't do anything, but it's worth a try..lol..and, yes you were right, it comes in that way. It's a huge file given to me, and I *assumed* (my mistake) that it was OK from their end.. thanks for pointing out the obvious, sometimes you just need a second set of eyes.. :)

This topic has been dead for over six months. 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.