pandas.errors.ParserError: Error could possibly be due to quotes being ignored when a multi-char delimiter is used.

From the Python regular expressions HOWTO, here is the list of metacharacters :

. ^ $ * + ? { } [ ] \ | ( )

In the Pandas library, while reading a csv with an uncommon delimiter such as |~|, you can have this error :

pandas.errors.ParserError: Error could possibly be due to quotes being ignored when a multi-char delimiter is used.

From the Pandas documentation, any delimiter longer than 1 character is considered as regular expressions. The multi-char delimiter is set up in the sep parameter.

For this example |~|, | is a metacharacter and to use it as a simple character, \ must be used. \ being itself a metacharacter, double quotes must be used : "\\|~\\|"

Pandas library version used : 0.24.2

Pandas User Guide : https://pandas.pydata.org/pandas-docs/stable/user_guide/index.html

Advertisements