[Baypiggies] adding hyperlinks to output

Vikram K kpguy1975 at gmail.com
Wed Jan 12 20:15:42 CET 2011


thanks for your response. I tried using the anchor tag but Excel is not
recognizing it as a hyperlink. This is my test script:

import csv
fout = open ('test.csv', 'w')

writer = csv.writer(fout)

writer.writerow(('Gene Link', 'Protein Link'))

writer.writerow(('<a href="http://www.ncbi.nlm.nih.gov/gene/9101">USP8</a>',
'bla'))

---------
the excel output for the above script is:

  Gene Link Protein Link

 <a href="http://www.ncbi.nlm.nih.gov/gene/9101">USP8</a> bla

On Wed, Jan 12, 2011 at 12:52 PM, Eric Walstad <eric at ericwalstad.com> wrote:
> Hi Vikram,
>
> On Wed, Jan 12, 2011 at 7:01 AM, Vikram K <kpguy1975 at gmail.com> wrote:
>> I have a bunch of symbols in one of the columns in my program's output
>> file (a csv file which can be opened in excel). I wish to add
>> hyperlinks to each entry in this particular column in my output file.
>> A sample symbol/entry in the specific column of interest in the output
>> file is USP8 and it needs to be hyperlinked to
>> http://www.ncbi.nlm.nih.gov/gene/9101. (So, when you click on 'USP8'
>> in the output file, your browser automatically opens the site
>> http://www.ncbi.nlm.nih.gov/gene/9101).
>>
>> Can someone tell me how to add hyperlinks to my output?
>
> If you write an anchor tag to your csv file Excel might/should
> recognize it as a hyperlink.  You could test that by editing one of
> the lines of an existing csv file by hand and then opening it in
> Excel.  If that does what you want, then modify your csv writer code
> to output an anchor tag:
>
> <a href="http://www.ncbi.nlm.nih.gov/gene/9101">USP8</a>
>
> If that's not what you are looking for it would be helpful to see a
> sample CSV file line and a description of how you are writing the
> lines to a file.
>
> Eric.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20110112/4534ca4b/attachment.html>


More information about the Baypiggies mailing list