import csv


def precip_table_etl_cnrccep(
    ws_precip,
    rainfall_adjustment=1
    ):
    """
    Extract, Transform, and Load data from a Cornell Northeast Regional
    Climate Center Extreme Precipitation estimates csv into an array
    
    Output: 1D array containing 24-hour duration estimate for frequencies 1,2,5,10,25,50,100,200 years. Example: 
        [5.207, 6.096, 7.5438, 8.8646, 10.9982, 12.9286, 15.2146, 17.907, 22.1996]
    
    """
    precips = []

    # Open the precipitation data csv and read all the precipitations out.
    with open(ws_precip) as g:
        input_precip= csv.reader(g)
        
        # Skip the first 10 rows of the csv, which are assorted header information.
        for j in range (1, 11):
            next(g)

        k=1
        for row in input_precip:
            # Grab data from column containing 24-hour estimate
            P=float(row[10])
            # convert to cm and adjust for future rainfall conditions (if rainfall_adjustment is > 1)
            precips.append(P*2.54*rainfall_adjustment)
            if k>8:
                break
            else:
                k=k+1
    return precips