Read a list of week-matrices from a CSV file.
326775
def read_csv(filename):
    

    with open(filename, 'r') as f:
        r = csv.reader(f)
        next(r)  # remove header
        wm = list(r)

    # remove header and convert to numeric
    for i, row in enumerate(wm):
        row[1:4] = map(int, row[1:4])
        row[4] = float(row[4])

    return wm
845662
def csv_to_dicts(file, header=None):
    """"""
    with open(file) as csvfile:
        return [row for row in csv.DictReader(csvfile, fieldnames=header)]
1293418
public static Basic1DMatrix fromCSV(String csv) {
        return Matrix.fromCSV(csv).to(Matrices.BASIC_1D);
    }
949625
def table2matrix(table):
    """"""

    if not is_simpletable(table):
        raise NotSimpleTable("Not able read a cell in the table as a string")
    rows = []
    for tr in table('tr'):
        row = []
        for td in tr('td'):
            td = tdbr2EOL(td) # convert any '<br>' in the td to line ending
            try:
                row.append(td.contents[0])
            except IndexError:
                row.append('')
        rows.append(row)
    return rows
1001488
def _read_csv_table(path):
    """"""
    with open(path, 'rb') as csvfile:
        reader = csv.DictReader(csvfile)
        table = list(reader)
    return table
854740
def from_csv(cls, path:PathOrStr, csv_name:str, cols:IntsOrStrs=0, delimiter:str=None, header:str='infer',
                 processor:PreProcessors=None, **kwargs)->'ItemList':
        """"""
        df = pd.read_csv(Path(path)/csv_name, delimiter=delimiter, header=header)
        return cls.from_df(df, path=path, cols=cols, processor=processor, **kwargs)
947528
def read_matlab_features(array_paths, number_of_nodes, dimensionality):
    
    # Read the data array
    file_row_gen = get_file_row_generator(array_paths[0], "\t")
    data = list()
    append_data = data.append
    for file_row in file_row_gen:
        append_data(float(file_row[0]))

    # Read the row array
    file_row_gen = get_file_row_generator(array_paths[1], "\t")
    row = list()
    append_row = row.append
    for file_row in file_row_gen:
        append_row(int(float(file_row[0])))

    # Read the data array
    file_row_gen = get_file_row_generator(array_paths[2], "\t")
    col = list()
    append_col = col.append
    for file_row in file_row_gen:
        append_col(int(float(file_row[0])))

    data = np.array(data).astype(np.float64)
    row = np.array(row).astype(np.int64) - 1  # Due to Matlab numbering
    col = np.array(col).astype(np.int64) - 1  # Due to Matlab numbering

    print(np.max(row), np.min(row))
    print(np.max(col), np.min(col))

    # centroids_new = sparse.coo_matrix((data, (row, col)), shape=(number_of_nodes + 1, k))
    features = spsp.coo_matrix((data, (row, col)), shape=(number_of_nodes, dimensionality))

    return features
97102
private static Matrix readMatlabSparse(
             File matrixFile,
             Type matrixType,
             boolean transposeOnRead) throws IOException {

         Matrix matrix = new GrowingSparseMatrix();
         BufferedReader br = new BufferedReader(new FileReader(matrixFile));
         for (String line = null; (line = br.readLine()) != null; ) {
             String[] rowColVal = line.split("\\s+");
             int row = Integer.parseInt(rowColVal[0]) - 1;
             int col = Integer.parseInt(rowColVal[1]) - 1;
             double value = Double.parseDouble(rowColVal[2]);
             if (transposeOnRead)
                 matrix.set(col, row, value);
             else
                 matrix.set(row, col, value);
         }
         br.close();
         return matrix;
     }
21566
def loadVectors(self, filename, cols = None, everyNrows = 1,
                    delim = ' ', checkEven = 1, patterned = 0):
        
        return self.loadVectorsFromFile(filename, cols, everyNrows,
                                        delim, checkEven, patterned)
1072364
def get_list_from_file(file_name):
    """"""
    with open(file_name, mode='r', encoding='utf-8') as f1:
        lst = f1.readlines()
    return lst
1326992
def _reduce_datetimes(row):
    """"""

    row = list(row)

    for i in range(len(row)):
        if hasattr(row[i], 'isoformat'):
            row[i] = row[i].isoformat()
    return tuple(row)
520683
private SortedSet<WeekOfMonth> readWeeksOfMonth(JSONValue json) {

        JSONArray array = null == json ? null : json.isArray();
        if (null != array) {
            SortedSet<WeekOfMonth> result = new TreeSet<>();
            for (int i = 0; i < array.size(); i++) {
                String weekStr = readOptionalString(array.get(i));
                try {
                    WeekOfMonth week = WeekOfMonth.valueOf(weekStr);
                    result.add(week);
                } catch (@SuppressWarnings("unused") IllegalArgumentException | NullPointerException e) {
                    // Just skip
                }
            }
            return result;
        }
        return new TreeSet<>();
    }
713029
def read(self, frame, data):
        ""
        seq = []
        while data:
            elem, data = self.spec.read(frame, data)
            seq.append(elem)
        return seq, data
233917
def load_csv(file, shape=None, normalize=False):
    
    value_list = []
    if six.PY2:
        for row in csv.reader(file):
            value_list.append(list(map(float, row)))
    elif six.PY34:
        for row in csv.reader([l.decode('utf-8') for l in file.readlines()]):
            value_list.append(list(map(float, row)))
    if shape is None:
        return numpy.array(value_list)
    else:
        return numpy.array(value_list).reshape(shape)
525746
def from_csv(self, input_data):
        
        reformatted_data = []
        for (i,row) in enumerate(input_data):
            if i==0:
                headers = row
            else:
                data_row = {}
                for (j,h) in enumerate(headers):
                    data_row.update({h : row[j]})
                reformatted_data.append(data_row)
        return reformatted_data
75417
def parse_250_row(row: list) -> BasicMeterData:
    
    return BasicMeterData(row[1], row[2], row[3], row[4], row[5],
                             row[6], row[7], float(row[8]),
                             parse_datetime(row[9]), row[10], row[11], row[12],
                             float(row[13]), parse_datetime(
                                 row[14]), row[15], row[16], row[17],
                             float(row[18]), row[19], row[20],
                             parse_datetime(row[21]), parse_datetime(row[22]))
590146
public static Basic2DMatrix fromCSV(String csv) {
        return Matrix.fromCSV(csv).to(Matrices.BASIC_2D);
    }