Skip to content

Instantly share code, notes, and snippets.

@rgkimball
rgkimball / rowcount.py
Last active August 9, 2021 03:11
File rowcount estimation
def count_file_iter(*ar, **kw):
"""
Small utility to iterate through individual rows of a file given a generator,
used only to count rows.
:param ar: args for open()
:param kw: keyword args for open()
:return: yields 1 for each row
"""
for _ in open(*ar, **kw):