Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Reading csv using pandas

$
0
0

So I am trying to convert a to using , One of the column has large numbers which is displayed like this in cells (-9.11211E+18) and on expanding it is like (-9112112386848730000)

But when I am using pandas to read that csv this particular cell is getting read as (`-9112112386848737971)

And then when I am using xlsx writer to write it to a new excel file it is being written as (-9112112386848740000)

My requirements is that it should write to new file exactly as it is in csv file, what could be done in this case, please help

Here is the code for the same that i am using

import pandas as pd

store = pd.read_csv (r'file_location_csv1')

target = pd.read_csv (r'file_location_csv2')

user = pd.read_csv (r'file_location_csv3')

product = pd.read_csv (r'file_location_csv4')

dfs = {'store_import_report':store, 'target_import_report':target, 'user_import_report':user,'product_import_report':product}

writer = pd.ExcelWriter('file_location_Excel.xlsx', engine='xlsxwriter')

for sheet_name in dfs.keys():
    dfs[sheet_name].to_excel(writer, sheet_name=sheet_name, index=False)

writer.save()

Viewing all articles
Browse latest Browse all 88835


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>