Python Forum
Dealing with Exponential data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dealing with Exponential data
#11
Yes opened in notepad++ my records are as
2229708157109620
2204081406354340
892984837048418000 respectively

Issue raised for me when i tried to join the records after reading it to pandas to my database records with database table, not able to join here as it has not different records
in csv 2229708157109620 have changed to 2229708157109627
in csv 2204081406354340 have changed to 2204081406354342
in csv 892984837048418000 have changed to 892984837048418304

database table has record as below
2229708157109620
2204081406354340
892984837048418000
Reply
#12
To close the thread once and for all

spam.csv - view it in notepad++

Output:
2229708157109627 2204081406354342 892984837048418304 2229708157109620 2204081406354340 892984837048418000
# using csv
import csv
print('Print the file using csv module')
with open('spam.csv') as f:
    rdr =  csv.reader(f)
    for line in rdr:
        num, =  line
        print(num) # here it prints it as str
        print(int(num)) # convert it to number


# and using pandas        
print('\nPrint the file as pandas dataframe')    
import pandas as pd
df = pd.read_csv('spam.csv',index_col=None, header=None)
print(df)
output
Output:
Print the file using csv module 2229708157109627 2229708157109627 2204081406354342 2204081406354342 892984837048418304 892984837048418304 2229708157109620 2229708157109620 2204081406354340 2204081406354340 892984837048418000 892984837048418000 Print the file as pandas dataframe 0 0 2229708157109627 1 2204081406354342 2 892984837048418304 3 2229708157109620 4 2204081406354340 5 892984837048418000
and here is what you will see in Excel when open the same file

   

e.g. in cell A3 you see 892984837048418000 but in fact in the file the value is 892984837048418304

Attached Files

.csv   spam.csv (Size: 112 bytes / Downloads: 116)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel from SAP - dealing with formats and VBA MasterOfDestr 7 457 Feb-25-2024, 12:23 PM
Last Post: Pedroski55
  UnicodeEncodeError - Dealing with Japanese Characters fioranosnake 2 2,353 Jul-07-2022, 08:43 PM
Last Post: fioranosnake
  how to get non-exponential format Skaperen 1 1,416 Nov-21-2021, 08:51 PM
Last Post: bowlofred
  Dealing with duplicated data in a CSV file bts001 10 11,198 Sep-06-2021, 12:11 AM
Last Post: SamHobbs
  Dealing with a .json nightmare... ideas? t4keheart 10 4,249 Jan-28-2020, 10:12 PM
Last Post: t4keheart
  understanding exponential and bitwise operators srm 1 2,001 Jun-15-2019, 11:14 AM
Last Post: ThomasL
  Dealing with multiple context managers heras 5 4,602 Nov-16-2018, 09:01 AM
Last Post: DeaD_EyE
  dealing with big data of timestamp LMQ 0 2,142 Jul-27-2018, 01:23 PM
Last Post: LMQ
  dealing with spaces in file names AceScottie 5 74,643 Jun-02-2018, 01:06 PM
Last Post: AceScottie
  Dealing with strings thru mmap in Python doublezero 4 7,936 Mar-01-2017, 06:33 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020