import csv

"""functions to read a csv file (filename) and append values to rowlists
within 2D list (environment), and to write an output file """

# create an environment from a csv file
def create_environment(filename):
    new_environment = []

    file = open(filename, newline='')
    dataset = csv.reader(file, quoting=csv.QUOTE_NONNUMERIC)

    for row in dataset:                     # A list of rows
        rowlist = []
        for value in row:				    # A list of value
            rowlist.append(value)           # Append values to rowlist
            # print(value) 				    # Prints floats
        new_environment.append(rowlist)     # Append rowlist to environment

    file.close()
    return new_environment

# write out the environment to a csv file
def write_environment(environment, filename):
    file = open(filename, 'w', newline='')
    writer = csv.writer(file, delimiter=' ')
    for row in environment:
        writer.writerow(row)    # List of values.
    file.close()

import csv

"""functions to read a csv file (filename) and append values to rowlists
within 2D list (environment), and to write an output file """

# create an environment from a csv file
def create_environment(filename):
    new_environment = []

    file = open(filename, newline='')
    dataset = csv.reader(file, quoting=csv.QUOTE_NONNUMERIC)

    for row in dataset:                     # A list of rows
        rowlist = []
        for value in row:				    # A list of value
            rowlist.append(value)           # Append values to rowlist
            # print(value) 				    # Prints floats
        new_environment.append(rowlist)     # Append rowlist to environment

    file.close()
    return new_environment

# write out the environment to a csv file
def write_environment(environment, filename):
    file = open(filename, 'w', newline='')
    writer = csv.writer(file, delimiter=' ')
    for row in environment:
        writer.writerow(row)    # List of values.
    file.close()

functions to read a csv file (filename) and append values to rowlists within 2D list (environment), and to write an output file # create an environment from a csv file # A list of rows # A list of value # Append values to rowlist # print(value) 				    # Prints floats # Append rowlist to environment # write out the environment to a csv file # List of values.