question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: could not convert string to float: 'C'

See original GitHub issue
In [3]: svg.path.parse_path("M 5 1 v 7.344 A 3.574 3.574 0 003.5 8 3.515 3.515 0 000 11.5 C 0 13.421 1.579 15 3.5 15 A 3.517 3.517 0 007 11.531 v -
   ...: 7.53 h 6 v 4.343 A 3.574 3.574 0 0011.5 8 3.515 3.515 0 008 11.5 c 0 1.921 1.579 3.5 3.5 3.5 1.9 0 3.465 -1.546 3.5 -3.437 V 1 z")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-5f3c4d12c583> in <module>
----> 1 svg.path.parse_path("M 5 1 v 7.344 A 3.574 3.574 0 003.5 8 3.515 3.515 0 000 11.5 C 0 13.421 1.579 15 3.5 15 A 3.517 3.517 0 007 11.531 v -7.53 h 6 v 4.343 A 3.574 3.574 0 0011.5 8 3.515 3.515 0 008 11.5 c 0 1.921 1.579 3.5 3.5 3.5 1.9 0 3.465 -1.546 3.5 -3.437 V 1 z")

~/.local/lib/python3.9/site-packages/svg/path/parser.py in parse_path(pathdef, current_pos)
    177             radius = float(elements.pop()) + float(elements.pop()) * 1j
    178             rotation = float(elements.pop())
--> 179             arc = float(elements.pop())
    180             sweep = float(elements.pop())
    181             end = float(elements.pop()) + float(elements.pop()) * 1j

ValueError: could not convert string to float: 'C'

Valid SVG:

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
  <path d="M 5 1 v 7.344 A 3.574 3.574 0 003.5 8 3.515 3.515 0 000 11.5 C 0 13.421 1.579 15 3.5 15 A 3.517 3.517 0 007 11.531 v -7.53 h 6 v 4.343 A 3.574 3.574 0 0011.5 8 3.515 3.515 0 008 11.5 c 0 1.921 1.579 3.5 3.5 3.5 1.9 0 3.465 -1.546 3.5 -3.437 V 1 z" style="line-height:normal;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration-line:none;text-transform:none;marker:none" color="#000" font-weight="400" font-family="Sans" overflow="visible" fill="#474747"/>
</svg>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
tatarizecommented, Mar 25, 2021

Yeah, svgelements has that as a function approximate_arcs_as_cubics() or something like that that’ll go through and replace the damned things. My personal preference is a circular arc with a control point and endpoint. You only need 3 points to define a circle and they’d be easy to write by hand, etc. I even raised and issue at WC3 for it. No joy.

0reactions
regebrocommented, Mar 29, 2021

“Mostly the existence of an unrecognized character is supposed to end the parsing right there.”

Oh, right, I totally forgot about that. Good call.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: could not convert string to float: id - Stack Overflow
Obviously some of your lines don't have valid float data, specifically some line have text id which can't be converted to float.
Read more >
Python valueerror: could not convert string to float Solution | CK
The “valueerror: could not convert string to float” error is raised when you try to convert a string that is not formatted as...
Read more >
ValueError: could not convert string to float in Python
The Python "ValueError: could not convert string to float" occurs when we pass a string that cannot be converted to a float (e.g....
Read more >
How to Fix in Pandas: could not convert string to float - Statology
This error usually occurs when you attempt to convert a string to a float in pandas, yet the string contains one or more...
Read more >
ValueError could not convert string to float id - Edureka
The problem is that in your code some lines don't have valid float data. In some lines, there is a text id that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found