I have converted a pandas DataFrame to an Excel sheet using df.to_excel.
Now, I want to add hyperlinks to the values in one column. In other words, when a customer
I was generating text files from a excel file and wanted to link the names of the generated .txt files to a particular existing column in the Dataframe.
I was trying to push the local drive directory where the generated .txt files are stored, to the corresponding "File Name". So that on clicking the file name, it will open the .txt file.
rancheck_DF = pd.read_excel(excel_file, delim_whitespace = True, encoding = 'utf-8')
for index_df in range(len(rancheck_DF)):
Desc = rancheck_DF.loc[index_df,'Description Text']
MainFile = rancheck_DF.loc[index_df,'File Name']
fileName = r'.\Documents\TestF\TestF_{}.txt'.format(index_df)
with open(fileName, 'w', encoding='utf-8') as txtfile:
txtfile.write(Desc)
rancheck_DF.loc[index_df,'File Name'] = '=HYPERLINK("{}","{}")'.format(fileName,MainFile)
rancheck_DF.to_excel('./damn.xlsx', index=None)