Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(0)  |  Derive(0)  |  Import(1)
Stream every line in the given file interpreting each line as a dictionary of fields to items.

:param filename: A ``str`` filename, A ``py._path.local.LocalPath`` instance or open ``file`` instnace.
:type filename:  ``str``, ``py._path.local.LocalPath`` or ``file``.

:param encoding: A ``str`` indicating the charset/encoding to use.
:type encoding:  ``str``

:param stripchars: An iterable of characters to strip from the surrounding line. ``line.strip(...)`` is used.
:type stripchars: ``list``, ``tuple`` or ``str``(more...)

        def csvdictstream(filename, encoding="utf-8", fields=None, stripchars="\r\n"):
    """Stream every line in the given file interpreting each line as a dictionary of fields to items.

    :param filename: A ``str`` filename, A ``py._path.local.LocalPath`` instance or open ``file`` instnace.
    :type filename:  ``str``, ``py._path.local.LocalPath`` or ``file``.

    :param encoding: A ``str`` indicating the charset/encoding to use.
    :type encoding:  ``str``

    :param stripchars: An iterable of characters to strip from the surrounding line. ``line.strip(...)`` is used.
    :type stripchars: ``list``, ``tuple`` or ``str``

    This is a wrapper around ``csvstream`` where the stream is treated as dict of field(s) to item(s).
    """

    stream = csvstream(filename, encoding=encoding, stripchars=stripchars)

    if fields is None:
        fields = map(strip, next(stream))

    for values in stream:
        yield compact(zipdict(fields, values))
        


src/s/t/streamio-0.0.9/streamio/__init__.py   streamio(Download)
from .stat import minmax  # noqa
from .sort import merge, mergesort  # noqa
from .stream import stream, csvstream, jsonstream, csvdictstream, compress  # noqa
 
__all__ = ("minmax", "merge", "mergesort", "stream", "csvstream", "jsonstream", "csvdictstream", "compress",)