kitir/_libs/file_utils.py
def iread_csv(file_name, return_headers=False, **kwargs):
    """
    iter-reads a csv file using DictReader and returns a rowdicts generator
    :param file_name: path of the file
    :param return_headers: first yield is the headers
    :return: rows read from csv as generator
    """
    filemode = kwargs.pop('filemode', 'r')
    log.trace('reading csv file: path={}'.format(file_name))
    if not check_file_size(file_name):
        # verify file is not empty
        log.warning('csv file size is 0 bytes: csv={}'.format(file_name))
        raise StopIteration()
    f = open(file_name, filemode)
    reader = DictReader(f)
    try:
        if return_headers:
            yield reader.fieldnames
        for row in reader:
            yield row
    except StopIteration:
        f.close()
    finally:
        f.close()

    iter-reads a csv file using DictReader and returns a rowdicts generator
    :param file_name: path of the file
    :param return_headers: first yield is the headers
    :return: rows read from csv as generator
    
iter-reads a csv file using DictReader and returns a rowdicts generator
iter - reads a csv file using DictReader and returns a rowdicts generator
def iread_csv(file_name, return_headers=False, **kwargs):
    filemode = kwargs.pop('filemode', 'r')
    log.trace('reading csv file: path={}'.format(file_name))
    if not check_file_size(file_name):
        log.warning('csv file size is 0 bytes: csv={}'.format(file_name))
        raise StopIteration()
    f = open(file_name, filemode)
    reader = DictReader(f)
    try:
        if return_headers:
            yield reader.fieldnames
        for row in reader:
            yield row
    except StopIteration:
        f.close()
    finally:
        f.close()
def iread_csv ( file_name , return_headers = False , ** kwargs ) : filemode = kwargs . pop ( 'filemode' , 'r' ) log . trace ( 'reading csv file: path={}' . format ( file_name ) ) if not check_file_size ( file_name ) : log . warning ( 'csv file size is 0 bytes: csv={}' . format ( file_name ) ) raise StopIteration ( ) f = open ( file_name , filemode ) reader = DictReader ( f ) try : if return_headers : yield reader . fieldnames for row in reader : yield row except StopIteration : f . close ( ) finally : f . close ( )
iter-reads a csv file using DictReader and returns a rowdicts generator
iter - reads a csv file using DictReader and returns a rowdicts generator
"""
    iter-reads a csv file using DictReader and returns a rowdicts generator
    :param file_name: path of the file
    :param return_headers: first yield is the headers
    :return: rows read from csv as generator
    """ # verify file is not empty
rows read from csv as generator
rows read from csv as generator
file_name
path of the file
path of the file
return_headers
first yield is the headers
first yield is the headers