Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFR-2349: Increasing CSV Field Size Limit #456

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion processes/ingest/hathi_trust.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

class HathiTrustProcess(CoreProcess):
HATHI_RIGHTS_SKIPS = ['ic', 'icus', 'ic-world', 'und']
FIELD_SIZE_LIMIT = 131072 * 2 # 131072 is the default size limit

def __init__(self, *args):
super(HathiTrustProcess, self).__init__(*args[:4], batchSize=1000)
Expand Down Expand Up @@ -106,6 +107,8 @@ def importFromHathiFile(self, hathi_url, start_date_time=None):
self.readHathiFile(hathi_tsv, start_date_time)

def readHathiFile(self, hathi_tsv, start_date_time=None):
csv.field_size_limit(self.FIELD_SIZE_LIMIT)

for number_of_books_ingested, book in enumerate(hathi_tsv):
if self.ingest_limit and number_of_books_ingested > self.ingest_limit:
break
Expand All @@ -114,7 +117,10 @@ def readHathiFile(self, hathi_tsv, start_date_time=None):
book_date_updated = (len(book) > 14 and book[14]) or None

if book_date_updated:
hathi_date_modified = datetime.strptime(book_date_updated, '%Y-%m-%d %H:%M:%S').replace(tzinfo=None)
try:
hathi_date_modified = datetime.strptime(book_date_updated, '%Y-%m-%d %H:%M:%S').replace(tzinfo=None)
except Exception:
hathi_date_modified = None

if book_right and book_right not in self.HATHI_RIGHTS_SKIPS:
if not start_date_time or hathi_date_modified >= start_date_time:
Expand Down
Loading