use csv reader for counting instead of 'wc -l'

This commit is contained in:
Luna 2022-08-28 16:49:08 -03:00
parent a44ef2a370
commit dab0de4448

View file

@ -197,14 +197,13 @@ async def main_with_ctx(ctx, wanted_date):
log.info("going to process posts")
line_count_str, _path = subprocess.check_output(
["wc", "-l", output_uncompressed_paths["posts"]]
).split()
line_count = int(line_count_str)
with output_uncompressed_paths["posts"].open(
mode="r", encoding="utf-8"
) as posts_csv_fd:
line_count = 0
counter_reader = csv.reader(posts_csv_fd)
for _row in counter_reader:
line_count += 1
line_count -= 1 # remove header
log.info("%d posts to import", line_count)