I have a UTF-8 encoded CSV with a column that contains the string representation of a WKB (i.e., string representation of bytes). I'm primarily interested in getting this string back into the original bytes, but when I read the CSV I get a string literal.

Assume that I cannot change how the data is stored in the CSV (i.e., save the column as WKT).

For example:

from shapely import wkb, geometry
point = wkb.dumps(geometry.Point(42.42, 42.42))
<class 'bytes'>
b'\x01\x01\x00\x00\x00\xf6(\\\x8f\[email protected]\xf6(\\\x8f\[email protected]'

The printed bytes in the above snippet are saved in a CSV file. I need to read that string from the CSV file back into the bytes it represents.

0 Answers