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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.