当前位置: 首页>>代码示例>>Python>>正文


Python DictReader.__init__方法代码示例

本文整理汇总了Python中csv.DictReader.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python DictReader.__init__方法的具体用法?Python DictReader.__init__怎么用?Python DictReader.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在csv.DictReader的用法示例。


在下文中一共展示了DictReader.__init__方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, fid, commentchar='#', *args, **kwds):
     if issubclass(DictReader, object):
         super(DictReader, self).__init__(fid, *args, **kwds)
     else:
         DictReader.__init__(self, fid, *args, **kwds)
     self.commentchar = commentchar
     self.leadingfield = self.commentchar + 'label'
开发者ID:BRAINSia,项目名称:rs-fMRI-pilot,代码行数:9,代码来源:seedWorkflow.py

示例2: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self,refGene_fn) :
     refGene_f = open(refGene_fn)
     # check for header
     first_line = refGene_f.next()
     if not first_line.strip().startswith('#') :
         refGene_f.seek(0) # first line not header, reset the file pointer
     DictReader.__init__(self,refGene_f,delimiter='\t',fieldnames=RefGeneOutput.FIELD_NAMES)
开发者ID:dvanderk,项目名称:chipsequtil,代码行数:9,代码来源:chipsequtil.py

示例3: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, f, fieldnames=None, restkey=None, restval=None,
              dialect="excel", *args, **kw):
     DictReader.__init__(self, f, fieldnames=fieldnames,
                         restkey=restkey, restval=restval,
                         dialect=dialect, *args, **kw)
     # Replace the reader with our unicode-enabled reader.
     self.reader = UnicodeReader(f, dialect=dialect, *args, **kw)
开发者ID:b8va,项目名称:everest,代码行数:9,代码来源:compat.py

示例4: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, f, fieldnames=None, restkey=None, restval=None,
              dialect="excel", encoding='utf-8', *args, **kw):
     DictReader.__init__(self, f, fieldnames=fieldnames,
                         restkey=restkey, restval=restval,
                         dialect=dialect, *args, **kw)
     if not encoding is None:
         f = Utf8Recoder(f, encoding=encoding)
     # Replace the reader with our unicode-enabled reader.
     self.reader = reader(f, dialect=dialect, *args, **kw)
开发者ID:helixyte,项目名称:everest,代码行数:11,代码来源:compat.py

示例5: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, f, fieldnames=None, restkey=None, restval=None,
              dialect="excel",
              encoding=None,
              *args, **kwds):
     BaseDictReader.__init__(self, f=f, fieldnames=fieldnames,
                             restkey=restkey, restval=restval,
                             dialect=dialect,
                             *args, **kwds)
     from .csv import reader
     self.reader = reader(f, dialect=dialect,
                          encoding=encoding,
                          **kwds)
开发者ID:caktus,项目名称:cordwainer,代码行数:14,代码来源:dicts.py

示例6: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, csvfile, fields=None, silent=False, **kwargs):
   self.csvfile = csvfile
   self.rows_imported = 0
   self.errors = []
   self.silent = silent
   if fields:
     if isinstance(fields[0], (list, tuple)):
       kwargs['fieldnames'] = [field[0] for field in fields]
       self.field_types = dict(fields)
     else:
       kwargs['fieldnames'] = fields
       self.field_types = dict.fromkeys(fields, None)
     DictReader.__init__(self, csvfile, **kwargs)
   else:
     DictReader.__init__(self, csvfile, **kwargs)
     self.field_types = dict.fromkeys(self.fieldnames, None)
开发者ID:colwilson,项目名称:flasker,代码行数:18,代码来源:util.py

示例7: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
    def __init__(self, csvfile, casts, fieldnames=None, restkey=None, 
                 restval=None, dialect='excel', *args, **kwds):
        """Arguments:
           - f: An iterable object such as as file. Passed on to 
             csv.DictReader
           - casts: A dict mapping from attribute names to functions to apply
             to these names, e.g., {'id':int, 'salary':float}
           - fieldnames: Passed on to csv.DictReader
           - restkey: Passed on to csv.DictReader
           - restval: Passed on to csv.DictReader
           - dialect: Passed on to csv.DictReader
           - *args: Passed on to csv.DictReader
           - **kwds: Passed on to csv.DictReader
        """
        DictReader.__init__(self, csvfile, fieldnames=fieldnames, 
                            restkey=restkey, restval=restval, dialect=dialect, 
                            *args, **kwds)

        if not type(casts) == dict:
            raise TypeError("The casts argument must be a dict")
        for v in casts.values():
            if not callable(v):
                raise TypeError("The values in casts must be callable")
        self._casts = casts
开发者ID:harryprince,项目名称:pygrametl,代码行数:26,代码来源:datasources.py

示例8: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, f):
     DictReader.__init__(self, f)
     self._node = Node(ROOT, [])
     self.col_num = 0
     self._init()
开发者ID:xinchunli,项目名称:new_era,代码行数:7,代码来源:csv_file.py

示例9: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, f, fieldnames=None, restkey=None, restval=None,
              dialect="excel", encoding="utf-8", *args, **kwargs):
     from csv import DictReader
     DictReader.__init__(self, f, fieldnames, restkey, restval,
                         dialect, *args, **kwargs)
     self.reader = UnicodeReader(f, dialect, encoding=encoding, *args, **kwargs)
开发者ID:gihandesilva,项目名称:django-fusionbox,代码行数:8,代码来源:unicode_csv.py

示例10: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, *args, **kwargs):
     DictReader.__init__(self, *args, **kwargs)
     self._fieldnames = map(slugify, self.fieldnames)
开发者ID:augustomen,项目名称:simple-data-importer,代码行数:5,代码来源:csv_reader.py

示例11: __init__

# 需要导入模块: from csv import DictReader [as 别名]
# 或者: from csv.DictReader import __init__ [as 别名]
 def __init__(self, *args, **kwargs):
     
     args = list(args)
     args[0] = utfify(args[0])
     
     DictReader.__init__(self, *args, **kwargs) #  DictReader is apparently an old-style  class
开发者ID:aplayford,项目名称:django-improv,代码行数:8,代码来源:__init__.py


注:本文中的csv.DictReader.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。