A dataframe extracted from email (email saved to local disk, ".msg"), that I am not able to read its content.
The dataframe extracted from email, when wrote to an Excel file, it looks like the screenshot.
It as extra lines on the front rows (#1, #2, #3) with grids. I've only worked with dataframe that normally has 1 top row (not sure if it's called Header).
What's wanted is to read the correspondent cells. For example, to get the First Name in the dataframe, I've tried:
first_name = df.loc[df['Field'] == 'First Name', 'Value'].iloc[0]
print (visitor_name)
It gives error:
ValueError: Cannot index with multidimensional key
How can I do with this type of dataframe? Thank you. (here is the saved Excel file,
CodePudding user response:
Did the following:
df = pd.read_excel('Sample.xlsx', engine='openpyxl')
print(df[df['Field'] == 'First Name']['Value'])
Output
6 David
If an error occurs, use the link
pip3 install openpyxl