CSV Reader factory for CADA format
328147
def reader(f):
    ''''''
    return unicodecsv.reader(f, encoding='utf-8', delimiter=b',', quotechar=b'"')
649820
def from_csv(cls, path:PathOrStr, folder:PathOrStr=None, label_delim:str=None, csv_labels:PathOrStr='labels.csv',
                 valid_pct:float=0.2, fn_col:int=0, label_col:int=1, suffix:str='', delimiter:str=None,
                 header:Optional[Union[int,str]]='infer', **kwargs:Any)->'ImageDataBunch':
        ""
        path = Path(path)
        df = pd.read_csv(path/csv_labels, header=header, delimiter=delimiter)
        return cls.from_df(path, df, folder=folder, label_delim=label_delim, valid_pct=valid_pct,
                fn_col=fn_col, label_col=label_col, suffix=suffix, **kwargs)
620113
public function fromCSV()
    {
        $output = $this->file();
        $base = $this->base();
        $file = fopen($base.$output, 'r');

        if (!$file) {
            return [];
        }

        $results = [];
        $row = 0;
        while (($data = fgetcsv($file, 0, ',')) !== false) {
            $row++;
            // Skip column names
            if ($row == 1) {
                continue;
            }
            /**
             * data[0] = ORIGINAL
             * data[1] = TRANSLATION
             * data[2] = CONTEXT
             */
            $translation = $this->translateCSV($data);
            if (!empty($translation)) {
                $results[$translation[0]] = $translation[1];
            }
        }

        return $results;
    }
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
144866
def read_tsv(cls, file_or_buffer: str):
        """"""
        df = pd.read_csv(file_or_buffer, sep='\t', index_col=0)
        df = df.where(pd.notnull(df), None)
        # Note: df.where(..., None) changes all column types to `object`.
        return cls(df)
39790
def read_csv(filename, keys=None, convert_types=False, **kwargs):
    '''
    

    '''
    df = pd.read_csv(filename)
    if convert_types:
        df = convert_types_slow(df)
    if keys:
        df = df[df['key'].isin(keys)]
    df = process_one(df)
    return df
908265
def gen_ccc(output, ascii_props=False, append=False, prefix=""):
    """"""

    obj = {}
    with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'DerivedCombiningClass.txt'), 'r', 'utf-8') as uf:
        for line in uf:
            if not line.startswith('#'):
                data = line.split('#')[0].split(';')
                if len(data) < 2:
                    continue
                span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
                if span is None:
                    continue
                name = format_name(data[1])

                if name not in obj:
                    obj[name] = []
                obj[name].extend(span)

    for x in range(0, 256):
        key = str(x)
        if key not in obj:
            obj[key] = []

    for name in list(obj.keys()):
        s = set(obj[name])
        obj[name] = sorted(s)

    not_explicitly_defined(obj, '0', is_bytes=ascii_props)

    # Convert characters values to ranges
    char2range(obj, is_bytes=ascii_props)

    with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
        if not append:
            f.write(HEADER)
        # Write out the Unicode properties
        f.write('%s_canonical_combining_class = {\n' % prefix)
        count = len(obj) - 1
        i = 0
        for k1, v1 in sorted(obj.items()):
            f.write('    "%s": "%s"' % (k1, v1))
            if i == count:
                f.write('\n}\n')
            else:
                f.write(',\n')
            i += 1
915125
def read(self):
        """"""
        # Validate file path
        assert os.path.isfile(self.file_path), 'No such file exists: ' + str(self.file_path)

        # Open CSV file and read contents
        with open(self.file_path, 'r') as f:
            reader = csv_builtin.reader(f)
            loaded_data = list(reader)

        # Force digits to become integers
        return juggle_types(loaded_data)
278127
def parse_csv(self, infile, delimiter=",", decimal_sep="."):
        ""
        keys = ('name','type','x1','y1','x2','y2','font','size',
            'bold','italic','underline','foreground','background',
            'align','text','priority', 'multiline')
        self.elements = []
        self.pg_no = 0
        if not PY3K:
            f = open(infile, 'rb')
        else:
            f = open(infile)
        for row in csv.reader(f, delimiter=delimiter):
            kargs = {}
            for i,v in enumerate(row):
                if not v.startswith("'") and decimal_sep!=".": 
                    v = v.replace(decimal_sep,".")
                else:
                    v = v
                if v=='':
                    v = None
                else:
                    v = eval(v.strip())
                kargs[keys[i]] = v
            self.elements.append(kargs)
        self.keys = [v['name'].lower() for v in self.elements]
1165892
def create_columns(self):
        """"""
        reader = self._get_csv_reader()
        headings = six.next(reader)
        try:
            examples = six.next(reader)
        except StopIteration:
            examples = []

        found_fields = set()
        for i, value in enumerate(headings):
            if i >= 20:
                break

            infer_field = self.has_headings and value not in found_fields

            to_field = (
                {
                    "date": "date",
                    "amount": "amount",
                    "description": "description",
                    "memo": "description",
                    "notes": "description",
                }.get(value.lower(), "")
                if infer_field
                else ""
            )

            if to_field:
                found_fields.add(to_field)

            TransactionCsvImportColumn.objects.update_or_create(
                transaction_import=self,
                column_number=i + 1,
                column_heading=value if self.has_headings else "",
                to_field=to_field,
                example=examples[i].strip() if examples else "",
            )
276214
public function read()
	{
		
		$csvPath = self::buildCsvFilePath($this->prefectureCode);
		
		$buf = mb_convert_encoding(
			file_get_contents($csvPath), 
			mb_internal_encoding(), 
			'sjis-win'
		);
		
		return $buf;
		
	}
904331
def read_csv(filename, delimiter=CSV_DELIMITER):
    
    with open(filename, 'r') as file:
        return list(csv.reader(file, delimiter=delimiter))
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
1124889
def generate_csv(data):
  """"""
  print(",".join([
      "ability_id",
      "link_name",
      "link_index",
      "button_name",
      "hotkey",
      "friendly_name",
      "remap_to",
      "mismatch",
  ]))
  for ability in sorted(six.itervalues(data.abilities),
                        key=lambda a: sort_key(data, a)):
    ab_id = ability.ability_id
    if ab_id in skip_abilities or (ab_id not in data.general_abilities and
                                   ab_id not in used_abilities):
      continue

    general = ""
    if ab_id in data.general_abilities:
      general = "general"
    elif ability.remaps_to_ability_id:
      general = ability.remaps_to_ability_id

    mismatch = ""
    if ability.remaps_to_ability_id:
      def check_mismatch(ability, parent, attr):
        if getattr(ability, attr) != getattr(parent, attr):
          return "%s: %s" % (attr, getattr(ability, attr))

      parent = data.abilities[ability.remaps_to_ability_id]
      mismatch = "; ".join(filter(None, [
          check_mismatch(ability, parent, "available"),
          check_mismatch(ability, parent, "target"),
          check_mismatch(ability, parent, "allow_minimap"),
          check_mismatch(ability, parent, "allow_autocast"),
          check_mismatch(ability, parent, "is_building"),
          check_mismatch(ability, parent, "footprint_radius"),
          check_mismatch(ability, parent, "is_instant_placement"),
          check_mismatch(ability, parent, "cast_range"),
      ]))

    print(",".join(str(s) for s in [
        ability.ability_id,
        ability.link_name,
        ability.link_index,
        ability.button_name,
        ability.hotkey,
        ability.friendly_name,
        general,
        mismatch,
    ]))
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
184376
public static CaduceusProgram read(@NonNull Resource resource) throws IOException {
      CaduceusProgram program = new CaduceusProgram();

      try (Reader reader = resource.reader()) {
         List<Object> rules = ensureList(new Yaml().load(reader), "Caduceus rules should be specified in a list");

         for (Object entry : rules) {
            Map<String, Object> ruleMap = ensureMap(entry, "Rule entry should be a map");
            String ruleName = Val.of(ruleMap.get("name")).asString();
            String pattern = Val.of(ruleMap.get("pattern")).asString();
            if (StringUtils.isNullOrBlank(pattern)) {
               throw new IOException("No pattern specified: " + entry);
            }
            if (StringUtils.isNullOrBlank(ruleName)) {
               throw new IOException("No rule name specified: " + entry);
            }

            List<CaduceusAnnotationProvider> annotationProviders = new LinkedList<>();
            if (ruleMap.containsKey("annotations")) {
               List<Object> annotationList = ensureList(ruleMap.get("annotations"),
                                                        "Annotations should be specified as a list.");
               for (Object o : annotationList) {
                  annotationProviders.add(CaduceusAnnotationProvider.fromMap(
                     ensureMap(o, "Annotation entries should be specified as a map."), resource.descriptor(),
                     ruleName));
               }
            }

            List<CaduceusRelationProvider> relationProviders = new LinkedList<>();
            if (ruleMap.containsKey("relations")) {
               List<Object> relations = ensureList(ruleMap.get("relations"),
                                                   "Relations should be specified as a list.");
               for (Object o : relations) {
                  relationProviders.add(
                     CaduceusRelationProvider.fromMap(ensureMap(o, "Relation entries should be specified as a map.")));
               }
            }

            try {
               program.rules.add(new CaduceusRule(resource.descriptor(),
                                                  ruleName,
                                                  TokenRegex.compile(pattern),
                                                  annotationProviders,
                                                  relationProviders));
            } catch (ParseException e) {
               throw new IOException("Invalid pattern for rule " + ruleName);
            }

         }

      }
      return program;
   }
1157765
function csv(arg) {
  return ( _.isArray(arg) ? arg :
           _.isObject(arg) ? _.values(arg) :
           [arg]).join(', ');
}