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?

Recommended Answers

All 5 Replies

use strings instead of numbers.

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 ......

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.

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.. :)

Be a part of the DaniWeb community

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