

def rowmapmany(table, rowgenerator, header, failonerror=False):
    "\n    Map each input row to any number of output rows via an arbitrary\n    function. E.g.::\n\n        >>> import petl as etl\n        >>> table1 = [['id', 'sex', 'age', 'height', 'weight'],\n        ...           [1, 'male', 16, 1.45, 62.0],\n        ...           [2, 'female', 19, 1.34, 55.4],\n        ...           [3, '-', 17, 1.78, 74.4],\n        ...           [4, 'male', 21, 1.33]]\n        >>> def rowgenerator(row):\n        ...     transmf = {'male': 'M', 'female': 'F'}\n        ...     yield [row[0], 'gender',\n        ...            transmf[row['sex']] if row['sex'] in transmf else None]\n        ...     yield [row[0], 'age_months', row.age * 12]\n        ...     yield [row[0], 'bmi', row.height / row.weight ** 2]\n        ...\n        >>> table2 = etl.rowmapmany(table1, rowgenerator,\n        ...                         header=['subject_id', 'variable', 'value'])\n        >>> table2.lookall()\n        +------------+--------------+-----------------------+\n        | subject_id | variable     | value                 |\n        +============+==============+=======================+\n        |          1 | 'gender'     | 'M'                   |\n        +------------+--------------+-----------------------+\n        |          1 | 'age_months' |                   192 |\n        +------------+--------------+-----------------------+\n        |          1 | 'bmi'        | 0.0003772112382934443 |\n        +------------+--------------+-----------------------+\n        |          2 | 'gender'     | 'F'                   |\n        +------------+--------------+-----------------------+\n        |          2 | 'age_months' |                   228 |\n        +------------+--------------+-----------------------+\n        |          2 | 'bmi'        | 0.0004366015456998006 |\n        +------------+--------------+-----------------------+\n        |          3 | 'gender'     | None                  |\n        +------------+--------------+-----------------------+\n        |          3 | 'age_months' |                   204 |\n        +------------+--------------+-----------------------+\n        |          3 | 'bmi'        | 0.0003215689675106949 |\n        +------------+--------------+-----------------------+\n        |          4 | 'gender'     | 'M'                   |\n        +------------+--------------+-----------------------+\n        |          4 | 'age_months' |                   252 |\n        +------------+--------------+-----------------------+\n\n    The `rowgenerator` function should accept a single row and yield zero or\n    more rows (lists or tuples).\n\n    See also the :func:`petl.transform.reshape.melt` function.\n\n    "
    return RowMapManyView(table, rowgenerator, header, failonerror=failonerror)

dataset/ETHPy150Open alimanfoo/petl/petl/transform/maps.py rowmapmany/original