bahaaldine / angular-csv-import

Angular component that lets you import and convert CSV file to JSON
MIT License
150 stars 89 forks source link

If separator is undefined csv behaves in unexpected way #71

Open llazzaro opened 7 years ago

llazzaro commented 7 years ago

I was using the lib and forgot to pass the separator parameter to the directive. When no value is passed the line:

var currentline=lines[i].split(new RegExp(content.separator+'(?![^"]*"(?:(?:[^"]*"){2})*[^"]*$)'));

Will use as regex the value 'undefined(?![^"]"(?:(?:[^"]"){2})[^"]$)' and the csv will not be correclty parsed.

I think we should raise and error or use comma as default value.

Let me know you desicion and I will be happy to open a pull request.