Read a csv file into a DataAccessObject

    :param fname: filename
13981
def read_csv(fname):
    
    values = defaultdict(list)
    with open(fname) as f:
        reader = csv.DictReader(f)
        for row in reader:
            for (k,v) in row.items():
                values[k].append(v)
    npvalues = {k: np.array(values[k]) for k in values.keys()}
    for k in npvalues.keys():
        for datatype in [np.int, np.float]:
            try:
                npvalues[k][:1].astype(datatype)
                npvalues[k] = npvalues[k].astype(datatype)
                break
            except:
                pass
    dao = DataAccessObject(npvalues)
    return dao
738890
def data_context(fn, mode="r"):
    
    with open(data_context_name(fn), mode) as f:
        return f.read()
787551
def read_csv_as_integer(csv_name, integer_columns, usecols=None):
    
    csv_path = os.path.join(DATA_FOLDER, csv_name)
    csv = pd.read_csv(csv_path, low_memory=False, usecols=usecols)
    for column in integer_columns:
        csv = csv[pd.to_numeric(csv[column], errors="coerce").notnull()]
    csv[integer_columns] = csv[integer_columns].apply(pd.to_numeric)
    return csv
1167421
def read_data_to_asp(file: str) -> List[str]:
    
    if file.endswith(".json"):
        with open(file) as f:
            data = json.load(f)
            return schema2asp(data2schema(data))
    elif file.endswith(".csv"):
        df = pd.read_csv(file)
        df = df.where((pd.notnull(df)), None)
        data = list(df.T.to_dict().values())
        schema = data2schema(data)
        asp = schema2asp(schema)
        return asp
    else:
        raise Exception("invalid file type")
1018706
def read_from_file(filename):
        
        with open(filename) as f:
            result = CP2KInputFile()
            try:
                while True:
                    result.load_children(f)
            except EOFError:
                pass
        return result
260679
def _read_columns_file(f):
    
    try:
        columns = json.loads(open(f, 'r').read(),
                             object_pairs_hook=collections.OrderedDict)
    except Exception as err:
        raise InvalidColumnsFileError(
            "There was an error while reading {0}: {1}".format(f, err))

    # Options are not supported yet:
    if '__options' in columns:
        del columns['__options']

    return columns
939691
def read(filename):
    
    import os
    here = os.path.dirname(os.path.abspath(__file__))
    with open(os.path.join(here, filename)) as fd:
        return fd.read()
466842
def read(fname):
		
		try:
			with open(fname, 'r') as f:
				data = json.load(f)
			return data

		except IOError:
			raise Exception('Could not open {0!s} for reading'.format((fname)))
430080
def load_data(self, filename, *args, **kwargs):
        
        # header keys
        header_param = self.parameters.get('header')  # default is None
        # data keys
        data_param = self.parameters['data']  # raises KeyError if no 'data'
        dtype = data_param['dtype']  # raises KeyError if no 'dtype'
        # convert to tuple and normal ASCII
        _utf8_list_to_ascii_tuple(dtype) if dtype else None  # -> tuple of str
        delimiter = data_param.get('delimiter')  # default is None
        skiprows = data_param.get('skiprows')  # default is None
        data_units = data_param.get('units', {})  # default is an empty dict
        data = {}  # a dictionary for data
        # open file for reading
        with open(filename, 'r') as fid:
            # read header
            if header_param:
                data.update(_read_header(fid, header_param))
                fid.seek(0)  # move cursor back to beginning
            # read data
            data_data = np.loadtxt(fid, dtype, delimiter=delimiter,
                                   skiprows=skiprows)
        # apply units
        data.update(_apply_units(data_data, data_units, fid.name))
        return data
68205
def read(fname, fail_silently=False):
        
        try:
            filepath = os.path.join(os.path.dirname(__file__), fname)
            with io.open(filepath, 'rt', encoding='utf8') as f:
                return f.read()
        except:
            if not fail_silently:
                raise
            return ''
894843
def read_csv(filename):
    

    with open(filename) as file:
        table = list(csv.reader(file))
    m = from_table(table)
    return m
687276
def readfile(filename):
    
    with open(path_expand(filename), 'r') as f:
        content = f.read()
    return content
738190
def read_gdf(fname):
    
    
    gdf_file = open(fname, 'r')
    gdf = []
    for l in gdf_file:
        data = l.split()
        gdf += [data]

    gdf = np.array(gdf, dtype=object)
    
    if gdf.size > 0:
        gdf[:, 0] = gdf[:, 0].astype(int)
        gdf[:, 1:] = gdf[:, 1:].astype(float)
    
    return np.array(gdf)
461433
def read(fname):
    "  "
    if exists(fname):
        return open(join(dirname(__file__), fname)).read()
283784
def from_csv(cls, filename: str):
        
        with open(filename, "r", encoding="utf-8") as f:
            reader = csv.reader(f, delimiter=unicode2str(","),
                                quotechar=unicode2str("\""),
                                quoting=csv.QUOTE_MINIMAL)
            entries = list()
            header_read = False
            elements = None
            for row in reader:
                if not header_read:
                    elements = row[1:(len(row) - 1)]
                    header_read = True
                else:
                    name = row[0]
                    energy = float(row[-1])
                    comp = dict()
                    for ind in range(1, len(row) - 1):
                        if float(row[ind]) > 0:
                            comp[Element(elements[ind - 1])] = float(row[ind])
                    entries.append(PDEntry(Composition(comp), energy, name))
        return cls(entries)
898490
def read_pandas(fname, *args, **kwargs):
    """"""
    if not os.path.exists(fname):
        raise ValueError('no data file `{}` found!'.format(fname))
    if fname.endswith('csv'):
        df = pd.read_csv(fname, *args, **kwargs)
    else:
        xl = pd.ExcelFile(fname)
        if len(xl.sheet_names) > 1 and 'sheet_name' not in kwargs:
            kwargs['sheet_name'] = 'data'
        df = pd.read_excel(fname, *args, **kwargs)
    return df
910687
def from_file(cls, filename):
        
        import csv
        with open(filename, 'r') as f:
            reader = csv.DictReader(f)
            row = reader.next()  # Only one row in the file
        try:
            cls.ACCESS_KEY_ID = row['Access Key Id']
            cls.SECRET_ACCESS_KEY = row['Secret Access Key']
        except KeyError:
            raise IOError('Invalid credentials format')