Why does python think each character in my list is an element?

Viewed 54

I wanted to use an Excel file in Python, so I converted it to csv. I couldn't read it properly as I usually read csv files, so I read it like a txt file.

I've read each row and appended them to a list, and now I want to make a list with a particular column. When I write my code to retrieve the elements in position "col number", I get a single letter instead of getting a string with the words that are between commas, which I need to put in the column list.

I think it might be a problem from reading the file, but I'm really not sure. Is there a better way to convert an xls to csv for Python, or to read the file into my list? Can I combine letters to make one element out of several elements in a list?

Thank you!

1 Answers

There are no need to change .xlsx to .csv or .txt. you can read excel file in python using pd.read_excel() method.

import pandas as pd

df = pd.read_excel (r'Path where the Excel file is stored\File name.xlsx', sheet_name='your Excel sheet name')
print (df)
Related