diff --git a/anki/importing/csvfile.py b/anki/importing/csvfile.py index 7b0458610..f6e651148 100644 --- a/anki/importing/csvfile.py +++ b/anki/importing/csvfile.py @@ -32,14 +32,15 @@ class TextImporter(NoteImporter): for row in reader: row = [unicode(x, "utf-8") for x in row] if len(row) != self.numFields: - log.append(_( - "'%(row)s' had %(num1)d fields, " - "expected %(num2)d") % { - "row": u" ".join(row), - "num1": len(row), - "num2": self.numFields, - }) - ignored += 1 + if row: + log.append(_( + "'%(row)s' had %(num1)d fields, " + "expected %(num2)d") % { + "row": u" ".join(row), + "num1": len(row), + "num2": self.numFields, + }) + ignored += 1 continue note = self.noteFromFields(row) notes.append(note) @@ -65,8 +66,8 @@ class TextImporter(NoteImporter): if self.data.startswith(codecs.BOM_UTF8): self.data = self.data[len(codecs.BOM_UTF8):] def sub(s): - return re.sub("^\#.*", "", s) - self.data = [sub(x)+"\n" for x in self.data.split("\n") if sub(x)] + return re.sub("^\#.*$", "__comment", s) + self.data = [sub(x)+"\n" for x in self.data.split("\n") if sub(x) != "__comment"] if self.data: if self.data[0].startswith("tags:"): tags = unicode(self.data[0][5:], "utf8").strip()