Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #350 from multinet-app/empty_csv_body
Browse files Browse the repository at this point in the history
Add validation failure for missing rows (body) in a CSV upload
  • Loading branch information
jjnesbitt committed Mar 19, 2020
2 parents 5e0411b + ced66c7 commit 277f634
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions multinet/uploaders/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ class InvalidRow(ValidationFailure):
fields: List[str]


@dataclass
class MissingBody(ValidationFailure):
"""Missing body in a CSV file."""


def validate_csv(rows: Sequence[MutableMapping]) -> None:
"""Perform any necessary CSV validation, and return appropriate errors."""
data_errors: List[ValidationFailure] = []

if not rows:
raise ValidationFailed([MissingBody()])

fieldnames = rows[0].keys()
if "_key" in fieldnames:
# Node Table, check for key uniqueness
Expand Down
Binary file added test/data/empty_body.csv
Binary file not shown.

0 comments on commit 277f634

Please sign in to comment.