Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
debug: log offending line
Browse files Browse the repository at this point in the history
  • Loading branch information
HassanJaveed84 committed Feb 6, 2024
1 parent fd025d6 commit eb57a52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion edx/analytics/tasks/export/database_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ def mapper(self, line):
key: course_id
value: tab separated row data
"""
values = csv_util.parse_line(line, dialect='mysqldump')
try:
values = csv_util.parse_line(line, dialect='mysqldump')
except csv.Error:
log.error('Error parsing line: %s', line)
print('Error parsing line: %s' % line)
raise
record = StudentModuleRecord(*values)

course_id = record.course_id
Expand Down
6 changes: 5 additions & 1 deletion edx/analytics/tasks/util/csv_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class MySQLExportDialect(MySQLPipeDialect):
def parse_line(line, dialect='excel'):
"""Parse one line of CSV in the dialect specified."""
# csv.reader requires an iterable per row, so we wrap the line in a list
parsed = csv.reader([line], dialect=dialect).next()
try:
parsed = csv.reader([line], dialect=dialect).next()
except csv.Error:
log.error('Error parsing line: %s', line)
raise

return parsed

Expand Down

0 comments on commit eb57a52

Please sign in to comment.