switch_model/wecc/get_inputs/get_inputs.py
def write_csv(data: Iterable[List], fname, headers: List[str], log=True):
    """Create CSV file from Iterable."""
    if log:
        print(f"\t{fname}.csv... ", flush=True, end="")
    with open(fname + ".csv", "w") as f:
        f.write(",".join(headers) + "\n")
        for row in data:
            # Replace None values with dots for Pyomo. Also turn all datatypes into strings
            row_as_clean_strings = [
                "." if element is None else str(element) for element in row
            ]
            f.write(
                ",".join(row_as_clean_strings) + "\n"
            )  # concatenates "line" separated by commas, and appends \n
    if log:
        print(len(data))
Create CSV file from Iterable.
Create CSV file from Iterable.
Create CSV file from Iterable .
def write_csv(data: Iterable[List], fname, headers: List[str], log=True):
    if log:
        print(f"\t{fname}.csv... ", flush=True, end="")
    with open(fname + ".csv", "w") as f:
        f.write(",".join(headers) + "\n")
        for row in data:
            row_as_clean_strings = [
                "." if element is None else str(element) for element in row
            ]
            f.write(
                ",".join(row_as_clean_strings) + "\n"
            )  
    if log:
        print(len(data))
def write_csv ( data : Iterable [ List ] , fname , headers : List [ str ] , log = True ) : if log : print ( f"\t{fname}.csv... " , flush = True , end = "" ) with open ( fname + ".csv" , "w" ) as f : f . write ( "," . join ( headers ) + "\n" ) for row in data : row_as_clean_strings = [ "." if element is None else str ( element ) for element in row ] f . write ( "," . join ( row_as_clean_strings ) + "\n" ) if log : print ( len ( data ) )
Create CSV file from Iterable.
Create CSV file from Iterable .
"""Create CSV file from Iterable.""" # Replace None values with dots for Pyomo. Also turn all datatypes into strings # concatenates "line" separated by commas, and appends \n
data
Iterable[List]
fname
headers
List[str]
log