Skip to content

Commit

Permalink
Trim input values. (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurva authored Oct 10, 2023
1 parent a34d096 commit d383700
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions simple/stats/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(
def do_import(self) -> None:
self._read_csv()
self._drop_ignored_columns()
self._trim_values()
self._resolve_entities()
self._rename_columns()

Expand All @@ -63,6 +64,10 @@ def _drop_ignored_columns(self):
if self.ignore_columns:
self.df.drop(columns=self.ignore_columns, axis=1, inplace=True)

def _trim_values(self):
self.df = self.df.map(lambda value: value.strip()
if isinstance(value, str) else value)

def _rename_columns(self) -> None:
df = self.df
df.columns.values[0] = constants.COLUMN_DCID
Expand Down
4 changes: 2 additions & 2 deletions simple/stats/sample/input/geoids.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
geoId,year,ignore1,var1,var2,ignore2
01,2021,foo,555,666,bar
122,2022,#N/A,321,123,baz
01,2021,foo,555, 666 ,bar
122,2022,#N/A,321 , 123,baz

0 comments on commit d383700

Please sign in to comment.