def __init__(self, fields, field_prefix=None):
"""
Initializes a new TSV writer
The first value of each fields tuple is the destination field name.
The second value is a str property path (e.g. "one.two.three") or
a callable that when passed a row returns a computed field value
Arguments:
fields (List): list of (str, str|callable) tuples
field_prefix (str): path prefix to prefix field lookups with
"""
self.fields = OrderedDict(fields)
self.columns = self.fields.keys()
self.field_mappers = {column: self.get_field_mapper(field) for (column, field) in fields}
self.prefix_mapper = attrgetter(field_prefix) if field_prefix is not None else None
评论列表
文章目录