diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2025-04-17 12:23:38 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2025-04-19 05:14:48 +0200 |
commit | 2abf2297aabb355b72c6ae9e0aaf350f7a6cbe9d (patch) | |
tree | dd1a157dc6e08a96fdb99d79a6cf2e43047f3650 /administrative-codes/csv2json | |
parent | 4bcf4d8a3229c89813cbf3c05f4ef14cc80202d9 (diff) |
Add type hints and refactor a bit to please pylint.
Diffstat (limited to 'administrative-codes/csv2json')
-rwxr-xr-x | administrative-codes/csv2json | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/administrative-codes/csv2json b/administrative-codes/csv2json index 7c22666..6dd6ad7 100755 --- a/administrative-codes/csv2json +++ b/administrative-codes/csv2json @@ -18,6 +18,8 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. #---------------------------------------------------------------------- +# pylint: disable=missing-module-docstring + import sys import csv from pathlib import Path @@ -25,13 +27,14 @@ import json basedir = Path(sys.argv[0]).parent data = {} -def readCSV(path): - with open(path, mode='r', newline='') as fp: +def readCSV(pathname): # pylint: disable=invalid-name + """Read CSV""" + with open(pathname, mode='r', newline='', encoding='utf-8') as fp: reader = csv.DictReader(fp, delimiter='\t', dialect='unix') for row in reader: code = row['Code'] if code in data: - raise Exception(f'Duplicate code {code}') + raise RuntimeError(f'Duplicate code {code}') data[code] = row['Name'] # The source (SCB) lists all codes in same file: they differ only in |