Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
writing urls with 2 '#' will raise ValueError: too many values to unpack #330
The issue is in worksheet.py in the write_url method, at this line "url, url_str = url.split('#')"
import xlsxwriter workbook = xlsxwriter.Workbook("whatever.xlsx") worksheet = workbook.add_worksheet() worksheet.write(0,0,"http://www.google.com/#string1#string2")
To fix it use this:
url,url_str = url.split('#',1)
That fixes the exception but it introduces another issue since Excel doesn't support urls with 2 # locations like this.
For example if you insert a url like
Your example however
So duplicating Excel's behaviour here will be tricky.
Do you have an example of real urls like this in use?
unfortunately no, and I think it's not a valid url, but something like that came from an user.
But what I would like in this case is just to save the string , and not raise the exception.
added a commit
Jan 16, 2016
It looks like Excel only strips the second # anchor when the cell is edited and not just when the file is saved so that isn't as bad as I originally thought. Still it is a good indication that you probably shouldn't be adding invalid urls to an Excel worksheet.
Either way, I've fixed the exception and pushed the fix in version 0.8.4: https://xlsxwriter.readthedocs.org/changes.html