This question already has an answer here:
0.000003
a value in excel cell converts into 3e-05
when read in python using panda pd.read_excel
. Here is my program below. I m new to python trying to learn . Please suggest .
import pandas as pd
import numpy as np
import os
import glob
os.chdir('C:\\Users\\Desktop\\Files\\')
files = glob.glob("CT.xls")
for f in files:
print(f)
x = pd.read_excel(f).replace(np.nan, '', regex=True)
cols = x.loc[0]
x.drop(x.index[[0]],inplace=True)
x.columns = cols
#-------------------
pipe_del =[]
for i,j in x.iterrows():
st = ''
for k in j:
st = st + (k).strip() + '|'
st = st[0:len(st)-1]
pipe_del.append(st)
newf = f.split('_')[0].split(' ')[0]+'_'+f.split('_')[0].split(' ')[1]+'_'+f.split('_')[0].split(' ')[2]+'_'+f.split('_')[1].split('.')[0]+'.csv'
with open(newf, "w") as output:
for i in pipe_del:
output.write("%s\n" % i)
try
and the print your result.
Be careful while changing your display settings, remember to visit the docs : https://pandas.pydata.org/pandas-docs/stable/options.html