mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
support PSV out of the box and make extending delims easier
This commit is contained in:
parent
5b10d7c45b
commit
cc742df71a
1 changed files with 3 additions and 4 deletions
|
@ -13,7 +13,7 @@ from anki.lang import _
|
|||
class TextImporter(NoteImporter):
|
||||
|
||||
needDelimiter = True
|
||||
patterns = ("\t", ";")
|
||||
patterns = ("\t", "|", ",", ";", ":")
|
||||
|
||||
def __init__(self, *args):
|
||||
NoteImporter.__init__(self, *args)
|
||||
|
@ -86,14 +86,13 @@ class TextImporter(NoteImporter):
|
|||
raise Exception("unknownFormat")
|
||||
self.dialect = None
|
||||
sniffer = csv.Sniffer()
|
||||
delims = [',', '\t', ';', ':']
|
||||
if not self.delimiter:
|
||||
try:
|
||||
self.dialect = sniffer.sniff("\n".join(self.data[:10]),
|
||||
delims)
|
||||
self.patterns)
|
||||
except:
|
||||
try:
|
||||
self.dialect = sniffer.sniff(self.data[0], delims)
|
||||
self.dialect = sniffer.sniff(self.data[0], self.patterns)
|
||||
except:
|
||||
pass
|
||||
if self.dialect:
|
||||
|
|
Loading…
Reference in a new issue