]> git.openstreetmap.org Git - nominatim.git/blobdiff - src/nominatim_db/tools/tiger_data.py
Simplify int/float manipulation
[nominatim.git] / src / nominatim_db / tools / tiger_data.py
index 85110ae53bd13125ebd0bfb6e8a0ab7fd67a20f2..7b8655703e6a250a6833b5934393b09c4121e8b2 100644 (file)
@@ -108,8 +108,7 @@ async def add_tiger_data(data_dir: str, config: Configuration, threads: int,
 
         async with QueryPool(dsn, place_threads, autocommit=True) as pool:
             with tokenizer.name_analyzer() as analyzer:
 
         async with QueryPool(dsn, place_threads, autocommit=True) as pool:
             with tokenizer.name_analyzer() as analyzer:
-                lines = 0
-                for row in tar:
+                for lineno, row in enumerate(tar, 1):
                     try:
                         address = dict(street=row['street'], postcode=row['postcode'])
                         args = ('SRID=4326;' + row['geometry'],
                     try:
                         address = dict(street=row['street'], postcode=row['postcode'])
                         args = ('SRID=4326;' + row['geometry'],
@@ -124,10 +123,8 @@ async def add_tiger_data(data_dir: str, config: Configuration, threads: int,
                                                     %s::INT, %s::TEXT, %s::JSONB, %s::TEXT)""",
                         args)
 
                                                     %s::INT, %s::TEXT, %s::JSONB, %s::TEXT)""",
                         args)
 
-                    lines += 1
-                    if lines == 1000:
+                    if not lineno % 1000:
                         print('.', end='', flush=True)
                         print('.', end='', flush=True)
-                    lines = 0
 
         print('', flush=True)
 
 
         print('', flush=True)