I have an excel file with the below cell content
\\pathxx01\xxx project\71 XXXX XXXXXXX Team\Landlord Billing/
However, when importing the excel into a pandas dataframe with pd.read_excel method, the string is truncated to
\\pathxx01\xxx project\71 XXXX XXXXXXX Team\Lan...
Is there any way to avoid this truncation and keep the original string?
CodePudding user response:
As determined from the comments, it's not actually being truncated. Pandas is just displaying it truncated because there is little screenspace where you're displaying it.
You can use this to force Pandas to display the full columns without truncating them:
pd.set_option('display.max_colwidth', -1)
CodePudding user response:
I solved similar issues using xlwings
library, very handy for reasing single cell values to a variable, numpy arrays and pandas dataframes.
A quick sample:
import xlwings as xw
import numpy as np
import pandas as pd
worksheet = xw.Book(file_path).sheets['Sheet1']
myCellValue= xw.Book(file_path).sheets['Sheet1'].range('M4').value
myArray= np.array(worksheet.range("A1:A100").value)
imho this works more solidly than other solutions.