luminoso_api/v4_json_stream.py
def transcode(input_filename, output_filename=None, date_format=None):
    """
    Convert a JSON or CSV file of input to a JSON stream (.jsons). This
    kind of file can be easily uploaded using `luminoso_api.upload`.
    """
    if output_filename is None:
        # transcode to standard output
        output = sys.stdout
    else:
        if output_filename.endswith('.json'):
            logger.warning("Changing .json to .jsons, because this program "
                           "outputs a JSON stream format that is not "
                           "technically JSON itself.")
            output_filename += 's'
        output = open(output_filename, 'w')

    for entry in open_json_or_csv_somehow(input_filename,
                                          date_format=date_format):
        output.write(json.dumps(entry, ensure_ascii=False).encode('utf-8'))
        output.write('\n')
    output.close()
def transcode(input_filename, output_filename=None, date_format=None):
    """
    Convert a JSON or CSV file of input to a JSON stream (.jsons). This
    kind of file can be easily uploaded using `luminoso_api.upload`.
    """
    if output_filename is None:
        # transcode to standard output
        output = sys.stdout
    else:
        if output_filename.endswith('.json'):
            logger.warning("Changing .json to .jsons, because this program "
                           "outputs a JSON stream format that is not "
                           "technically JSON itself.")
            output_filename += 's'
        output = open(output_filename, 'w')

    for entry in open_json_or_csv_somehow(input_filename,
                                          date_format=date_format):
        output.write(json.dumps(entry, ensure_ascii=False).encode('utf-8'))
        output.write('\n')
    output.close()
Convert a JSON or CSV file of input to a JSON stream (.jsons). This
    kind of file can be easily uploaded using `luminoso_api.upload`.