Load list of words from UTF-8 file (one word per line).
178065
private Set<String> loadWords(InputStream stream) throws IOException {
    Set<String> words = new HashSet<>();
    try (
      InputStreamReader isr = new InputStreamReader(stream, "UTF-8");
      BufferedReader br = new BufferedReader(isr)
    ) {
      String line;
      while ((line = br.readLine()) != null) {
        line = line.trim();
        if (line.isEmpty() || line.charAt(0) == '#') {  // ignore comments
          continue;
        }
        words.add(line);
      }
    }
    return words;
  }
687631
def readlines(self, *args, **kwargs):
        """"""
        return list(iter(partial(self.readline, *args, **kwargs), u''))
1092211
def _load_from_file_object(self, f):
    
    subtoken_strings = []
    for line in f:
      s = line.strip()
      # Some vocab files wrap words in single quotes, but others don't
      if ((s.startswith("'") and s.endswith("'")) or
          (s.startswith("\"") and s.endswith("\""))):
        s = s[1:-1]
      subtoken_strings.append(native_to_unicode(s))
    self._init_subtokens_from_list(subtoken_strings)
    self._init_alphabet_from_tokens(subtoken_strings)
1183496
def load_pickle(file, encoding=None):
    
    # TODO: test set encoding='latin1' for 2/3 incompatibility
    if encoding:
        with open(file, 'rb') as f:
            return pickle.load(f, encoding=encoding)

    with open(file, 'rb') as f:
       return pickle.load(f)
767665
def idf2txt(txt):
    """"""
    astr = nocomment(txt)
    objs = astr.split(';')
    objs = [obj.split(',') for obj in objs]
    objs = [[line.strip() for line in obj] for obj in objs]
    objs = [[_tofloat(line) for line in obj] for obj in objs]
    objs = [tuple(obj) for obj in objs]
    objs.sort()

    lst = []
    for obj in objs:
        for field in obj[:-1]:
            lst.append('%s,' % (field, ))
        lst.append('%s;\n' % (obj[-1], ))

    return '\n'.join(lst)
695709
def file_to_list(in_file):
    '''  '''
    lines = []
    for line in in_file:
        # Strip new line
        line = line.strip('\n')

        # Ignore empty lines
        if line != '':
            # Ignore comments
            if line[0] != '#':
                lines.append(line)

    return lines
1072364
def get_list_from_file(file_name):
    """"""
    with open(file_name, mode='r', encoding='utf-8') as f1:
        lst = f1.readlines()
    return lst
392138
def load_stream(filename):
    """"""
    rawfile = pkg_resources.resource_stream(__name__, filename)
    if six.PY2:
        return rawfile
    return io.TextIOWrapper(rawfile, 'utf-8')
66203
def load_csvf(fpath, fieldnames, encoding):
    
    with open(fpath, mode='r', encoding=encoding) as f:
        snippet = f.read(8192)
        f.seek(0)

        dialect = csv.Sniffer().sniff(snippet)
        dialect.skipinitialspace = True
        return list(csv.DictReader(f, fieldnames=fieldnames, dialect=dialect))
704988
def load_file(self, cursor, target, fname, options):
        ""
        with open(fname) as fin:
            log.debug("opening {0} in {1} load_file".format(fname, __name__))
            encoding = options.get('encoding', 'utf-8')
            if target in self.processors:
                reader = self.processors[target](fin, encoding=encoding)
            else:
                reader = self.default_processor(fin, encoding=encoding)
            columns = getattr(reader, 'output_columns', None)
            for _ in xrange(int(options.get('skip-lines', 0))):
                fin.readline()
            cursor.copy_from(reader, self.qualified_names[target],
                             columns=columns)
1339249
private List<String> readFile(File file) throws Exception {
        List<String> content = new ArrayList<>(100);
        try (BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"))) {
            String line;
            while ((line = is.readLine()) != null) {
                content.add(line);
            }
            return content;
        }
    }
1007426
def utf8(item):
    """"""
    if isinstance(item, list):
        return [utf8(i) for i in item]
    if isinstance(item, tuple):
        return tuple([utf8(i) for i in item])
    if isinstance(item, dict):
        return {utf8(k): utf8(v) for k, v in item.items()}
    try:
        return item.decode('utf-8')
    except:  # bare except since this method is supposed to be safe anywhere
        return item
955384
def readlines(self):
        """"""
        if self.grammar:
            tot = []
            # Used this way instead of a 'for' loop against
            # self.file.readlines() so that there wasn't two copies of the file
            # in memory.
            while 1:
                line = self.file.readline()
                if not line:
                    break
                tot.append(line)
            return tot
        return self.file.readlines()
485939
def load(self, text, fieldnames=None):
    """"""
    lines = text.split('\n')
    fieldnames = load_line(lines[0])
    values = load_line(lines[1])
    self.__dict__ = dict(zip(fieldnames, values))
491815
def readlines(self, encoding=None):
        """"""
        try:
            encoding = encoding or ENCODING
            with codecs.open(self.path, encoding=None) as fi:
                return fi.readlines()
        except:
            return []
465120
def load(self, encoding='utf8', encoding_errors='ignore'):  # pylint: disable=arguments-differ
        
        if isinstance(self.codec, codec.NoCodec) and \
           self.fs.load_text != FileSystem.load_text:
            stream = self.fs.load_text(encoding, encoding_errors)
        else:
            stream = self.fs.load()
            stream = self.codec.decompress(stream)
            stream = TextIOWrapper(stream, encoding, encoding_errors)
        return stream
433074
def read(filename, encoding='utf-8'):
    
    text, encoding = decode( open(filename, 'rb').read() )
    return text, encoding