CSV and Excel are not the same datatype.
You can load the excel data into a pandas dataframe and then convert it to a pyspark dataframe.
first, you have to install the openpyxl library
%pip install openpyxl
Then import PySpark Pandas:
import pyspark.pandas as ps
And then read the excel-data into a df:
path = "/Volumes/demo/raw/files/FinancialsSampleData.xlsx"
# create pandas-df
pdf_sheet1 = ps.read_excel(path, sheet_name="Financials1")
#convert pandas-df to pyspark-df
df_sheet1 = pdf_sheet1.to_spark()
display(df_sheet1)
Your df should look like this:
