Reads a Hector contraint CSV file and returns it as a Pandas Series
492138
def read_hector_constraint(constraint_file):
    
    df = pd.read_csv(constraint_file, index_col=0, comment=";")
    df = df[df.applymap(lambda x: isinstance(x, (int, float)))]
    df.index = df.index.astype(int)
    return df.iloc[:, 0]
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)
227328
def from_pandas(cls, series):
        
        from pandas import Index as PandasIndex, MultiIndex as PandasMultiIndex

        if isinstance(series.index, PandasIndex):
            baloo_index = Index.from_pandas(series.index)
        elif isinstance(series.index, PandasMultiIndex):
            baloo_index = MultiIndex.from_pandas(series.index)
        else:
            raise TypeError('Cannot convert pandas index of type={} to baloo'.format(type(series.index)))

        return _series_from_pandas(series, baloo_index)
281728
def read_hdf (self, key, **kwargs):
        
        # This one needs special handling because of the "key" and path input.
        import pandas
        return pandas.read_hdf (text_type (self), key, **kwargs)
115792
def cast_values_csvs(d, idx, x):
    
    try:
        d[idx].append(float(x))
    except ValueError:
        d[idx].append(x)
        # logger_misc.warn("cast_values_csv: ValueError")
        # logger_misc.warn("ValueError: col: {}, {}".format(x, e))
    except KeyError as e:
        logger_misc.warn("cast_values_csv: KeyError: col: {}, {}".format(x, e))

    return d
956713
def csv(self, fh):
        
        self._matches.to_csv(fh, encoding='utf-8', float_format='%d',
                             index=False)
        return fh
399451
def parse_csv_response(data, unit_handler):
    """"""
    return squish([parse_csv_dataset(d, unit_handler) for d in data.split(b'\n\n')])
1260130
def read_csv(fname, sep=','):
    
    with open(fname, encoding='utf-8-sig') as f:
        header = next(f).strip().split(sep)
        dt = numpy.dtype([(h, numpy.bool if h == 'vs30measured' else float)
                          for h in header])
        return numpy.loadtxt(f, dt, delimiter=sep)
969885
def read_hector_output(csv_file):
    
    # Filter out spin-up values. In Hector 1.x RCP output streams years are
    # given as end of simulation year.
    # See https://github.com/JGCRI/hector/issues/177
    start_year = 1746
    output_stream = pd.read_csv(csv_file, skiprows=1)

    wide = output_stream[output_stream.year >= start_year].pivot_table(
        index="year", columns="variable", values="value"
    )

    return wide
1259285
def read_csv_with_different_type(csv_name, column_types_dict, usecols=None):
    
    csv_path = os.path.join(DATA_FOLDER, csv_name)
    csv = pd.read_csv(
        csv_path,
        usecols=usecols,
        encoding="utf-8",
        dtype=column_types_dict,
        engine="python",
    )

    for key_column, val_type in column_types_dict.items():
        if val_type == str:
            csv[key_column] = csv[key_column].str.strip()

    return csv
771544
def read_ix(ix, **kwargs):
    
    if not isinstance(ix, ixmp.TimeSeries):
        error = 'not recognized as valid ixmp class: {}'.format(ix)
        raise ValueError(error)

    df = ix.timeseries(iamc=False, **kwargs)
    df['model'] = ix.model
    df['scenario'] = ix.scenario
    return df, 'year', []
471990
def read_csv(filepath):
    
    symbols = []
    with open(filepath, 'rb') as csvfile:
        spamreader = csv.DictReader(csvfile, delimiter=',', quotechar='"')
        for row in spamreader:
            symbols.append(row)
    return symbols
1052744
def getCSVReader(data, reader_type=csv.DictReader):
        """"""
        f = StringIO(data[:-4])  # Remove \nEOF
        return reader_type(f)
851137
def importcsv(self):
        '''  '''
        csv_path = os.path.join(os.path.dirname(__file__), self.stock_no_files)
        with open(csv_path) as csv_file:
            csv_data = csv.reader(csv_file)
            result = {}
            for i in csv_data:
                try:
                    result[i[0]] = str(i[1]).decode('utf-8')
                except ValueError:
                    if i[0] == 'UPDATE':
                        self.last_update = str(i[1]).decode('utf-8')
                    else:
                        pass
        return result
576210
def load_csv(self):
        
        if path.exists(self.csv_filepath):
            self.results = self.results.append(
                pandas.read_csv(self.csv_filepath))
131392
def read_hdf5_timeseries(h5f, path=None, start=None, end=None, **kwargs):
    
    # read data
    kwargs.setdefault('array_type', TimeSeries)
    series = read_hdf5_array(h5f, path=path, **kwargs)
    # crop if needed
    if start is not None or end is not None:
        return series.crop(start, end)
    return series
14739
def dtypes(self):
        
        return Series(np.array(list(self._gather_dtypes().values()), dtype=np.bytes_),
                      self.keys())