def write_csv_to_file(d):
    """
    Writes columns of data to a target CSV file.

    :param dict d: A dictionary containing one list for every data column. Keys: int, Values: list
    :return None:
    """
    logger_csvs.info("enter write_csv_to_file")

    try:
        for filename, data in d.items():
            try:
                l_columns = _reorder_csv(data, filename)
                rows = zip(*l_columns)
                with open(filename, 'w+') as f:
                    w = csv.writer(f)
                    for row in rows:
                        row2 = decimal_precision(row)
                        w.writerow(row2)
            except TypeError as e:
                print("Error: Unable to write values to CSV file, {}:\n"
                      "(1) The data table may have 2 or more identical variables. Please correct the LiPD file manually\n"
                      "(2) There may have been an error trying to prep the values for file write. The 'number' field in the data columns may be a 'string' instead of an 'integer' data type".format(filename))
                print(e)
            except Exception as e:
                print("Error: CSV file not written, {}, {}:\n"
                      "The data table may have 2 or more identical variables. Please correct the LiPD file manually".format(filename, e))
    except AttributeError as e:
        logger_csvs.error("write_csv_to_file: Unable to write CSV File: {}".format(e, exc_info=True))
    logger_csvs.info("exit write_csv_to_file")
    return
def write_csv_to_file ( d ) : logger_csvs . info ( "enter write_csv_to_file" ) try : for filename , data in d . items ( ) : try : l_columns = _reorder_csv ( data , filename ) rows = zip ( * l_columns ) with open ( filename , 'w+' ) as f : w = csv . writer ( f ) for row in rows : row2 = decimal_precision ( row ) w . writerow ( row2 ) except TypeError as e : print ( "Error: Unable to write values to CSV file, {}:\n" "(1) The data table may have 2 or more identical variables. Please correct the LiPD file manually\n" "(2) There may have been an error trying to prep the values for file write. The 'number' field in the data columns may be a 'string' instead of an 'integer' data type" . format ( filename ) ) print ( e ) except Exception as e : print ( "Error: CSV file not written, {}, {}:\n" "The data table may have 2 or more identical variables. Please correct the LiPD file manually" . format ( filename , e ) ) except AttributeError as e : logger_csvs . error ( "write_csv_to_file: Unable to write CSV File: {}" . format ( e , exc_info = True ) ) logger_csvs . info ( "exit write_csv_to_file" ) return
Writes columns of data to a target CSV file.

    :param dict d: A dictionary containing one list for every data column. Keys: int, Values: list
    :return None: