humlab / penelope

Pipleline for generating data used in text analytics notebooks. Used by Welfare State Analytics, INIDUN and several other research projects.
5 stars 1 forks source link

Replacing `"'"` with `"\'"` doesn't do anything #188

Open jorendorff opened 1 year ago

jorendorff commented 1 year ago

:wave: Hi, apologies for the drive-by bug report, but today I did a search for .replace("'", "\'") and this line of code in Penelope came up.

This is a bug: "'" and "\'" are the same string.

>>> "'" == "\'"
True

The code is intended to escape the string, which would require replacing "'" with "\\'".

But after fixing that, backslashes in the CSV still wouldn't be handled property. It might be better to use json.dumps() here and remove the single-quotes on line 28.