Ecotrust / TEKDB

Traditional Ecological Knowledge Ethnographic Database Application
https://demo.itkdb.org/
MIT License
5 stars 2 forks source link

Broken Import: handle strings with double quotes and strings with single-quote/comma #95

Open rhodges opened 7 years ago

rhodges commented 7 years ago

single quotes are escaped with another single quote: "he'll" becomes "he''ll"

If that single quote (or apostrophe) is right before a comma, that breaks the current regex pattern: eg_match = r'(E\'".+?(?!\)"\'|E\'.*?(?!\)\'|.+?)(?:,\s|$)' import_sql near line 180

It also fails on strings with double quotes, which switch from: E'I\'m a string!' to E\'I\'m a "string"!\' so that it can be single quoted

rhodges commented 7 years ago

gave all str() functions "or ''" so 'NoneType' was never returned. Trying to str that was breaking everything.

rhodges commented 7 years ago

Here's an example to test against: 'E\'There were things at place, (999) xx\'\'x xx\'\'xxx\'\'x\'\'9,\'\', "thing preposition verbed," but thing2 stuff, "new statement."\', E\'0\', E\'0\', E\'0\'' should parse to [(string), "E'0'", E'0'", E'0'"] (len: 4)