Process dates in librarything import
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
""" handle reading a tsv from librarything """
|
||||
import re
|
||||
from . import Importer
|
||||
|
||||
|
||||
@ -8,3 +9,11 @@ class LibrarythingImporter(Importer):
|
||||
service = "LibraryThing"
|
||||
delimiter = "\t"
|
||||
encoding = "ISO-8859-1"
|
||||
|
||||
def normalize_row(self, entry, mappings): # pylint: disable=no-self-use
|
||||
"""use the dataclass to create the formatted row of data"""
|
||||
normalized = {k: entry.get(v) for k, v in mappings.items()}
|
||||
for date_field in self.date_fields:
|
||||
date = normalized[date_field]
|
||||
normalized[date_field] = re.sub(r"\[|\]", "", date)
|
||||
return normalized
|
||||
|
Reference in New Issue
Block a user