Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit 151f8ae

Browse files
Hal SekiHal Seki
authored andcommitted
20190401 の all_prefectures.csv で「交付件数基準日」が一部NULL
fixes #75
1 parent e55d827 commit 151f8ae

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

converter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ def appendData(self, list: list, created_at: date):
298298
self._alllist.extend(self.convert(list, created_at))
299299
else:
300300
self._alllist = self.convert(list, created_at) + self._alllist[1:]
301+
self._alllist = StringUtil.complement_error_lines(
302+
self._alllist, 6, True)
301303

302304

303305
class LocalgovsConverter(Converter):

stringutil.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,28 @@ def fix_line(line: list, start_row: int, end_row: int) -> list:
147147
if (end_row < len(line)):
148148
ret = ret + line[end_row]
149149
return ret
150+
151+
@staticmethod
152+
def complement_error_lines(lists: list, row_index: int,
153+
skip_first_line: bool) -> list:
154+
ret = []
155+
if (skip_first_line):
156+
ret.append(lists.pop(0))
157+
fill_data = ""
158+
isEmpty = False
159+
for lst in lists:
160+
if (lst[row_index] is not None and lst[row_index] != ""):
161+
fill_data = lst[row_index]
162+
if (isEmpty):
163+
break
164+
else:
165+
isEmpty = True
166+
if (fill_data != ''):
167+
break
168+
if ((not isEmpty) or fill_data == ""):
169+
return ret + lists
170+
for lst in lists:
171+
if (lst[row_index] is None or lst[row_index] == ""):
172+
lst[row_index] = fill_data
173+
ret.append(lst)
174+
return ret

0 commit comments

Comments
 (0)