def do(parser=None, args=None, in_=None, table_function=None):
    """Read command-line args and stdin, return the result.

    Read the command line arguments and the input data from stdin, pass them to
    the table() function to do the filter and transform, and return the string
    of CSV- or JSON-formatted text that should be written to stdout.

    Note that although the output data is returned rather than written to
    stdout, this function may write error messages or help text to stdout
    (for example if there's an error with the command-line parsing).

    :raises CommandLineError: see parse() above for details

    """
    in_ = in_ or sys.stdin
    table_function = table_function or losser.table

    parsed_args = parse(parser=parser, args=args)

    # Read the input data from stdin or a file.
    if parsed_args.input_data:
        input_data = open(parsed_args.input_data, 'r').read()
    else:
        input_data = in_.read()
    dicts = json.loads(input_data)

    csv_string = table_function(dicts, parsed_args.columns, csv=True,
                                pretty=parsed_args.pretty)

    return csv_string
Read command-line args and stdin, return the result.

    Read the command line arguments and the input data from stdin, pass them to
    the table() function to do the filter and transform, and return the string
    of CSV- or JSON-formatted text that should be written to stdout.

    Note that although the output data is returned rather than written to
    stdout, this function may write error messages or help text to stdout
    (for example if there's an error with the command-line parsing).

    :raises CommandLineError: see parse() above for details