0

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))
print(type(point))
print(point)
<class 'bytes'>
b'\x01\x01\x00\x00\x00\xf6(\\\x8f\xc25E@\xf6(\\\x8f\xc25E@'

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.

Tim Reddy
  • 4,340
  • 1
  • 40
  • 77

0 Answers0