diff --git a/frappe/utils/csvutils.py b/frappe/utils/csvutils.py index fd3a20b8ba..8ad7db41d2 100644 --- a/frappe/utils/csvutils.py +++ b/frappe/utils/csvutils.py @@ -2,7 +2,6 @@ # License: MIT. See LICENSE import csv import json -from csv import Sniffer from io import StringIO import requests @@ -58,28 +57,9 @@ def read_csv_content(fcontent): fcontent = fcontent.encode("utf-8") content = [frappe.safe_decode(line) for line in fcontent.splitlines(True)] - sniffer = Sniffer() - # Don't need to use whole csv, if more than 20 rows, use just first 20 - sample_content = content[:20] if len(content) > 20 else content - # only testing for most common delimiter types, this later can be extended - # init default dialect, to avoid lint errors - dialect = csv.get_dialect("excel") - try: - # csv by default uses excel dialect, which is not always correct - dialect = sniffer.sniff(sample="\n".join(sample_content), delimiters=frappe.flags.delimiter_options) - except csv.Error: - # if sniff fails, show alert on user interface. Fall back to use default dialect (excel) - frappe.msgprint( - _( - "Delimiter detection failed. Try to enable custom delimiters and adjust the delimiter options as per your data." - ), - indicator="orange", - alert=True, - ) - try: rows = [] - for row in csv.reader(content, dialect=dialect): + for row in csv.reader(content): r = [] for val in row: # decode everything