Skip to content

Commit

Permalink
Add handling for NA values during CSV validation
Browse files Browse the repository at this point in the history
  • Loading branch information
bencap committed Sep 11, 2024
1 parent 42e5520 commit fa984bb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mavedb/lib/mave/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import re

import pandas as pd

NA_VALUE = "NA"

NULL_VALUES = ("", "na", "nan", "nil", "none", "null", "n/a", "undefined", NA_VALUE)
Expand All @@ -22,6 +24,9 @@

def is_csv_null(value):
"""Return True if a string from a CSV file represents a NULL value."""
# Avoid any boolean miscasts from comparisons by handling NA types up front.
if pd.isna(value):
return True
# Number 0 is treated as False so that all 0 will be converted to NA value.
if value == 0:
return value
Expand Down

0 comments on commit fa984bb

Please sign in to comment.