0

I made an excel sheet using pandas dataframe to generate texts with clickable urls using the following code

import pandas as pd
df = pd.DataFrame({'link':['=HYPERLINK("https://ar.wikipedia.org/wiki/","wikipidia")',
                           '=HYPERLINK("https://www.google.com", "google")']})
df.to_excel('links.xlsx')

But currently i need to read the generated excel sheet (links.xlsx) using pandas.read_excel so i tried the following code:

import pandas as pd
excelDf=pd.read_excel('links.xlsx')
print(excelDf)

but this generates a dataframe with all zeroes in the link column. Is there another way I can read the excel file i created, or another way to create an excel sheet containing clickable links on text using pandas dataframe that is readable?

1 Answers1

0

you can do the same as a csv which is cleaner (avoids excel issues).

# %% write the date

import pandas as pd
df = pd.DataFrame({'link':['=HYPERLINK("https://ar.wikipedia.org/wiki/","wikipidia")',
                           '=HYPERLINK("https://www.google.com", "google")']})
df.to_csv('F:\\links.xlsx')



# %%  read the data

import pandas as pd
excelDf=pd.read_csv('F:\\links.xlsx')
print(excelDf)

result:

   Unnamed: 0                                               link
0           0  =HYPERLINK("https://ar.wikipedia.org/wiki/","w...
1           1     =HYPERLINK("https://www.google.com", "google")
D.L
  • 4,339
  • 5
  • 22
  • 45