Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
20190401 の all_prefectures.csv で「交付件数基準日」が一部NULL
fixes  #75
  • Loading branch information
Hal Seki authored and Hal Seki committed Jul 24, 2020
1 parent e55d827 commit 151f8ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions converter.py
Expand Up @@ -298,6 +298,8 @@ def appendData(self, list: list, created_at: date):
self._alllist.extend(self.convert(list, created_at))
else:
self._alllist = self.convert(list, created_at) + self._alllist[1:]
self._alllist = StringUtil.complement_error_lines(
self._alllist, 6, True)


class LocalgovsConverter(Converter):
Expand Down
25 changes: 25 additions & 0 deletions stringutil.py
Expand Up @@ -147,3 +147,28 @@ def fix_line(line: list, start_row: int, end_row: int) -> list:
if (end_row < len(line)):
ret = ret + line[end_row]
return ret

@staticmethod
def complement_error_lines(lists: list, row_index: int,
skip_first_line: bool) -> list:
ret = []
if (skip_first_line):
ret.append(lists.pop(0))
fill_data = ""
isEmpty = False
for lst in lists:
if (lst[row_index] is not None and lst[row_index] != ""):
fill_data = lst[row_index]
if (isEmpty):
break
else:
isEmpty = True
if (fill_data != ''):
break
if ((not isEmpty) or fill_data == ""):
return ret + lists
for lst in lists:
if (lst[row_index] is None or lst[row_index] == ""):
lst[row_index] = fill_data
ret.append(lst)
return ret

0 comments on commit 151f8ae

Please sign in to comment.