jQuery CSV parser shows CSVDataError: Illegal state

Just a quick troubleshooting tip. If you are trying to use the jQuery CSV data parser on Mac, it might give you this error:

CSVDataError: Illegal state [Row:1]

The reason is likely your CSV file that was saved on a Mac. Apparently, line endings on Macs use special characters, and the parser “chokes” on them and spits out this error.

To get around this, clean the input by adding this line of code:

// Normalize new lines
result = result.replace(/[r|rn]/g, "n");

This worked for me, hope you find this helpful! (via this link)

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 )

Facebook photo

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

Connecting to %s