Felix
Felix

Reputation: 1579

python pandas create hyperlink to image file while writing csv

This is data frame i am working with: {'Image File': {0: 'C:\Users\Param1.png', 1: 'C:\Users\Param2.png', 2: 'C:\Users\Param3.png'}, 'Param': {0: 'Param1', 1: 'Param2', 2: 'Param3'}} I would like to create hyper link in csv file to Image File with following statement:

Data['HYPERLINK'] = "<a href=\"Test\">"+Data['Image File']+"</a>"

My problem that as hyperlink i see the path i am supplying in "Image File" column, but i am interested in Param column value be as caption for hyperlink. any thoughts? Thank you

Upvotes: 0

Views: 2092

Answers (1)

chris-sc
chris-sc

Reputation: 1718

If you want the link text shown being your Param field, you need to add it to the link. In your example syntax this would be:

Data['HYPERLINK'] = "<a href=\"" + Data['Image File'] + "\">"+Data['Param']+"</a>"

The html link syntax is

<a href="url">link text</a>

see here for details: http://www.w3schools.com/html/html_links.asp

Upvotes: 2

Related Questions