Reads a Hector output stream CSV file and returns a wide DataFrame with
    Hector output data.
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
399451
def parse_csv_response(data, unit_handler):
    """"""
    return squish([parse_csv_dataset(d, unit_handler) for d in data.split(b'\n\n')])
328147
def reader(f):
    ''''''
    return unicodecsv.reader(f, encoding='utf-8', delimiter=b',', quotechar=b'"')
161672
def read_csv(self, dtype=False, parse_dates=True, *args, **kwargs):
        

        import pandas

        t = self.resolved_url.get_resource().get_target()

        kwargs = self._update_pandas_kwargs(dtype, parse_dates, kwargs)

        return pandas.read_csv(t.fspath, *args, **kwargs)
640589
def output_to_csv(sources, csv_writeable_file):
    """"""
    file_exists = os.path.isfile(csv_writeable_file)

    with open(csv_writeable_file, 'a') as csvfile:
        csv_dict = OrderedDict()
        csv_dict.update({'Time': time.strftime("%Y-%m-%d_%H:%M:%S")})
        summaries = [val for key, val in sources.items()]
        for summarie in summaries:
            csv_dict.update(summarie.source.get_sensors_summary())

        fieldnames = [key for key, val in csv_dict.items()]
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

        if not file_exists:
            writer.writeheader()  # file doesn't exist yet, write a header
        writer.writerow(csv_dict)
636097
def load_df_from_file(file_path, sep=",", header=0):
  """"""
  with tf.gfile.Open(file_path) as infile:
    df = pd.read_csv(infile, sep=sep, header=header)
  return df
493876
def create_df_file_with_query(self, query, output):
        
        chunk_size = 100000
        offset = 0
        data = defaultdict(lambda : defaultdict(list))

        with open(output, 'wb') as outfile:
            query = query.replace(';', '')
            query += """ LIMIT {chunk_size} OFFSET {offset};"""
            while True:
                print(offset)
                query = query.format(
                    chunk_size=chunk_size,
                    offset=offset
                )
                df = pd.read_sql(query, self.engine)
                pickle.dump(df, outfile)
                offset += chunk_size
                if len(df) < chunk_size:
                    break
            outfile.close()
968934
def load_data(verbose=False):
    ""

    df = pd.read_csv(STOPS_PATH, usecols=['stop_id', 'stop_name'])
    if verbose:
        print('- Loaded %d entries from "%s".' % (len(df), STOPS_PATH))
    return df
1081186
def _conv(self, data):
        """"""
        if isinstance(data, pd.Series):
            if data.name is None:
                data = data.to_frame(name='')
            else:
                data = data.to_frame()
        data = data.fillna('NaN')
        return data
871767
def bucketCSVs(csvFile, bucketIdx=2):
  """"""
  try:
    with open(csvFile, "rU") as f:
      reader = csv.reader(f)
      headers = next(reader, None)
      dataDict = OrderedDict()
      for lineNumber, line in enumerate(reader):
        if line[bucketIdx] in dataDict:
          dataDict[line[bucketIdx]].append(line)
        else:
          # new bucket
          dataDict[line[bucketIdx]] = [line]
  except IOError as e:
    print e

  filePaths = []
  for i, (_, lines) in enumerate(dataDict.iteritems()):
    bucketFile = csvFile.replace(".", "_"+str(i)+".")
    writeCSV(lines, headers, bucketFile)
    filePaths.append(bucketFile)

  return filePaths
386359
def get(self, stream, fmt='txt', **kwargs):
        """"""
        sel = ''.join(["&{0}={1}".format(k, v) for (k, v) in kwargs.items()])
        url = "streamds/{0}.{1}?{2}".format(stream, fmt, sel[1:])
        data = self._db._get_content(url)
        if not data:
            log.error("No data found at URL '%s'." % url)
            return
        if (data.startswith("ERROR")):
            log.error(data)
            return
        if fmt == "txt":
            return read_csv(data)
        return data
315323
def _readcsv(self, path_to_csv):
        """"""
        return np.genfromtxt(path_to_csv,
                             dtype=None,
                             delimiter=',',
                             names=True)
405568
public void generateCsv(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
        ICsvMapWriter csvWriter = null;
        try {
            csvWriter = new CsvMapWriter(new OutputStreamWriter(out), CsvPreference.STANDARD_PREFERENCE);
            // the header elements are used to map the bean values to each column (names must match)
            String[] header = new String[] {};
            CellProcessor[] processors = new CellProcessor[] {};
            if (columns != null)
            {
                header = (String[])CollectionUtils.collect(columns, new Transformer() {
                    @Override
                    public Object transform(Object input) {
                        ColumnDef column = (ColumnDef)input;
                        return column.getName();
                    }
                }).toArray(new String[0]) ;
                processors = (CellProcessor[]) CollectionUtils.collect(columns, new Transformer() {
                    @Override
                    public Object transform(Object input) {
                        return new Optional();
                    }
                }).toArray(new CellProcessor[0]);
            } else if (rows.size() > 0)
            {
                header = new ArrayList<String>(rows.get(0).keySet()).toArray(new String[0]);
                processors = (CellProcessor[]) CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
                    @Override
                    public Object transform(Object input) {
                        return new Optional();
                    }
                }).toArray(new CellProcessor[0]);
            }
            if (header.length > 0)
                csvWriter.writeHeader(header);
            if (rows != null)
                for (Map<String, Object> row : rows)
                {
                    csvWriter.write(row, header, processors);
                }
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } finally {
            if( csvWriter != null ) {
                try {
                    csvWriter.close();
                } catch (IOException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }
            }
        }
    }
390259
def _pipe(content):
    
    response = _data_frame(content).to_csv(index=False,sep='|')
    return response
43925
def _read(**kwargs):
    
    pd_obj = BaseFactory.read_csv(**kwargs)
    # This happens when `read_csv` returns a TextFileReader object for iterating through
    if isinstance(pd_obj, pandas.io.parsers.TextFileReader):
        reader = pd_obj.read
        pd_obj.read = lambda *args, **kwargs: DataFrame(
            query_compiler=reader(*args, **kwargs)
        )
        return pd_obj
    return DataFrame(query_compiler=pd_obj)
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
1133945
def load(self):
        
        # read file, keep all values as strings
        df = pd.read_csv(self.input_file,
                         sep=',',
                         quotechar='"',
                         encoding='utf-8',
                         dtype=object)

        # wer are only interested in the NUTS code and description, rename them also
        df = df[['NUTS-Code', 'Description']]
        df.columns = ['key', 'name']

        # we only want NUTS2 regions (4-digit codes)
        df = df[df['key'].str.len() == 4]

        # drop 'Extra Regio' codes ending in 'ZZ'
        df = df[df['key'].str[2:] != 'ZZ']

        return df