Skip to content

Issue with flatten function when some records contain nested values and others are blank #22

@allanw

Description

@allanw

The flatten function (

def flatten(d, parent_key='', sep='__'):
) will return a dictionary with the correctly flattened values if a nested value exists. However, if another record in the same input source contains the same key and is blank, the recursive call to flatten will not return anything, and so that key will not be present in the return value.

In the example above, the dictionaries returned from flatten will have different numbers of keys, which causes a problem when writing the output to a CSV (i.e. the number of columns will differ).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions