Python Forum
Dealing with Exponential data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dealing with Exponential data
#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: 122)
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


Messages In This Thread
Dealing with Exponential data - by parthi1705 - May-29-2019, 10:07 AM
RE: Dealing with Exponential data - by buran - May-29-2019, 10:20 AM
RE: Dealing with Exponential data - by parthi1705 - May-29-2019, 10:25 AM
RE: Dealing with Exponential data - by buran - May-29-2019, 10:40 AM
RE: Dealing with Exponential data - by parthi1705 - May-30-2019, 04:27 AM
RE: Dealing with Exponential data - by buran - May-29-2019, 11:02 AM
RE: Dealing with Exponential data - by DeaD_EyE - May-29-2019, 01:45 PM
RE: Dealing with Exponential data - by buran - May-30-2019, 06:48 AM
RE: Dealing with Exponential data - by parthi1705 - May-30-2019, 09:06 AM
RE: Dealing with Exponential data - by buran - May-30-2019, 09:16 AM
RE: Dealing with Exponential data - by parthi1705 - May-30-2019, 09:58 AM
RE: Dealing with Exponential data - by buran - May-30-2019, 10:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel from SAP - dealing with formats and VBA MasterOfDestr 7 616 Feb-25-2024, 12:23 PM
Last Post: Pedroski55
  UnicodeEncodeError - Dealing with Japanese Characters fioranosnake 2 2,501 Jul-07-2022, 08:43 PM
Last Post: fioranosnake
  how to get non-exponential format Skaperen 1 1,459 Nov-21-2021, 08:51 PM
Last Post: bowlofred
  Dealing with duplicated data in a CSV file bts001 10 11,614 Sep-06-2021, 12:11 AM
Last Post: SamHobbs
  Dealing with a .json nightmare... ideas? t4keheart 10 4,424 Jan-28-2020, 10:12 PM
Last Post: t4keheart
  understanding exponential and bitwise operators srm 1 2,063 Jun-15-2019, 11:14 AM
Last Post: ThomasL
  Dealing with multiple context managers heras 5 4,741 Nov-16-2018, 09:01 AM
Last Post: DeaD_EyE
  dealing with big data of timestamp LMQ 0 2,183 Jul-27-2018, 01:23 PM
Last Post: LMQ
  dealing with spaces in file names AceScottie 5 75,331 Jun-02-2018, 01:06 PM
Last Post: AceScottie
  Dealing with strings thru mmap in Python doublezero 4 8,087 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