Python csv.QUOTE_NONE属性代码示例

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

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

示例1: __init__

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def __init__(self,
                 root: str,
                 url: str = URL,
                 folder_in_archive: str = FOLDER_IN_ARCHIVE,
                 download: bool = False) -> None:
        basename = os.path.basename(url)
        archive = os.path.join(root, basename)
        basename = basename.split(self._ext_archive)[0]
        folder_in_archive = os.path.join(basename, folder_in_archive)
        self._path = os.path.join(root, folder_in_archive)
        self._metadata_path = os.path.join(root, basename, 'metadata.csv')
        if download:
            if not os.path.isdir(self._path):
                if not os.path.isfile(archive):
                    checksum = _CHECKSUMS.get(url, None)
                    download_url(url, root, hash_value=checksum)
                extract_archive(archive)
        with open(self._metadata_path, "r") as metadata:
            walker = unicode_csv_reader(metadata, delimiter="|", quoting=csv.QUOTE_NONE)
            self._walker = list(walker) 
开发者ID:pytorch,项目名称:audio,代码行数:27,代码来源:ljspeech.py


示例2: parse_geoplanet_places_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def parse_geoplanet_places_csv(csv_file):
    csv_reader = csv.reader(open(csv_file, 'rb'), dialect='excel-tab', quoting=csv.QUOTE_NONE)
    for row in csv_reader:
            out_line = ['P', row[0], row[1], row[6], row[7], row[8], row[10], row[18]+" 00:00:00+00", "POINT("+row[5]+" "+row[4]+")" ]
            print "\t".join(out_line)
    return csv_file
 #* WOE_ID                      0- primary "place" key
  #* ISO                         1- ISO 3166-1 country/territory code
  #* State                       2- WOEID of admin state
  #* County                      3- WOEID of admin county
  #* Local_Admin                 4- WOEID of local admin
  #* Country                     5- WOEID of country
  #* Continent                   6- WOEID of continent 
开发者ID:LibraryOfCongress,项目名称:gazetteer,代码行数:18,代码来源:parse_geoplanet.py


示例3: test_dialect

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_dialect(all_parsers):
    parser = all_parsers
    data = """\
label1,label2,label3
index1,"a,c,e
index2,b,d,f
"""
    dia = csv.excel()
    dia.quoting = csv.QUOTE_NONE
    df = parser.read_csv(StringIO(data), dialect=dia)
    data = """\
label1,label2,label3
index1,a,c,e
index2,b,d,f
"""
    exp = parser.read_csv(StringIO(data))
    exp.replace("a", "\"a", inplace=True)
    tm.assert_frame_equal(df, exp) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:test_dialect.py


示例4: test_multi_char_sep_quotes

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_multi_char_sep_quotes(python_parser_only, quoting):
    # see gh-13374
    kwargs = dict(sep=",,")
    parser = python_parser_only
    data = 'a,,b\n1,,a\n2,,"2,,b"'
    msg = "ignored when a multi-char delimiter is used"
    def fail_read():
        with pytest.raises(ParserError, match=msg):
            parser.read_csv(StringIO(data), quoting=quoting, **kwargs)
    if quoting == csv.QUOTE_NONE:
        # We expect no match, so there should be an assertion
        # error out of the inner context manager.
        with pytest.raises(AssertionError):
            fail_read()
    else:
        fail_read() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_python_parser_only.py


示例5: export_to_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def export_to_csv(request, variants):
    #export to csv
    export = request.GET.get('export', '')
    if export != '':
        if export == 'csv':
            response = HttpResponse(content_type='text/csv')
            response['Content-Disposition'] = 'attachment; filename=export.csv'
            writer = csv.writer(response)
        elif export == 'txt':
            response = HttpResponse(content_type='text/plain')
            response['Content-Disposition'] = 'attachment; filename=export.txt'
            writer = csv.writer(response, delimiter='\t', quoting=csv.QUOTE_NONE)
        writer.writerow(['Individual', 'Index', 'Pos_index', 'Chr', 'Pos', 'Variant_id', 'Ref', 'Alt', 'Qual', 'Filter', 'Info', 'Format', 'Genotype_col', 'Genotype', 'Read_depth', 'Gene', 'Mutation_type', 'Vartype', 'Genomes1k_maf', 'Dbsnp_maf', 'Esp_maf', 'Dbsnp_build', 'Sift', 'Sift_pred', 'Polyphen2', 'Polyphen2_pred', 'Condel', 'Condel_pred', 'DANN', 'CADD', 'Is_at_omim', 'Is_at_hgmd', 'Hgmd_entries', 'Effect', 'Impact', 'Func_class', 'Codon_change', 'Aa_change', 'Aa_len', 'Gene_name', 'Biotype', 'Gene_coding', 'Transcript_id', 'Exon_rank', 'Genotype_number', 'Allele', 'Gene', 'Feature', 'Feature_type', 'Consequence', 'Cdna_position', 'Cds_position', 'Protein_position', 'Amino_acids', 'Codons', 'Existing_variation', 'Distance', 'Strand', 'Symbol', 'Symbol_source', 'Sift', 'Polyphen', 'Condel'])
        for variant in variants:
            # print 'variant', variant.index
            writer.writerow([variant.individual, variant.index, variant.pos_index, variant.chr, variant.pos, variant.variant_id, variant.ref, variant.alt, variant.qual, variant.filter, pickle.loads(variant.info), variant.format, variant.genotype_col, variant.genotype, variant.read_depth, variant.gene, variant.mutation_type, variant.vartype, variant.genomes1k_maf, variant.dbsnp_maf, variant.esp_maf, variant.dbsnp_build, variant.sift, variant.sift_pred, variant.polyphen2, variant.polyphen2_pred, variant.condel, variant.condel_pred, variant.dann, variant.cadd, variant.is_at_omim, variant.is_at_hgmd, variant.hgmd_entries])
        return response 
开发者ID:raonyguimaraes,项目名称:mendelmd,代码行数:20,代码来源:filter_options.py


示例6: test_write_arg_valid

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_write_arg_valid(self):
        self._write_error_test(csv.Error, None)
        self._write_test((), '')
        self._write_test([None], '""')
        self._write_error_test(csv.Error, [None], quoting = csv.QUOTE_NONE)
        # Check that exceptions are passed up the chain
        class BadList:
            def __len__(self):
                return 10;
            def __getitem__(self, i):
                if i > 2:
                    raise IOError
        self._write_error_test(IOError, BadList())
        class BadItem:
            def __str__(self):
                raise IOError
        self._write_error_test(IOError, [BadItem()]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_csv.py


示例7: test_write_escape

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_write_escape(self):
        self._write_test(['a',1,'p,q'], 'a,1,"p,q"',
                         escapechar='\\')
        self._write_error_test(csv.Error, ['a',1,'p,"q"'],
                               escapechar=None, doublequote=False)
        self._write_test(['a',1,'p,"q"'], 'a,1,"p,\\"q\\""',
                         escapechar='\\', doublequote = False)
        self._write_test(['"'], '""""',
                         escapechar='\\', quoting = csv.QUOTE_MINIMAL)
        self._write_test(['"'], '\\"',
                         escapechar='\\', quoting = csv.QUOTE_MINIMAL,
                         doublequote = False)
        self._write_test(['"'], '\\"',
                         escapechar='\\', quoting = csv.QUOTE_NONE)
        self._write_test(['a',1,'p,q'], 'a,1,p\\,q',
                         escapechar='\\', quoting = csv.QUOTE_NONE) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_csv.py


示例8: test_lineterminator

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_lineterminator(self):
        class mydialect(csv.Dialect):
            delimiter = ";"
            escapechar = '\\'
            doublequote = False
            skipinitialspace = True
            lineterminator = '\r\n'
            quoting = csv.QUOTE_NONE
        d = mydialect()
        self.assertEqual(d.lineterminator, '\r\n')
        mydialect.lineterminator = ":::"
        d = mydialect()
        self.assertEqual(d.lineterminator, ":::")
        mydialect.lineterminator = 4
        with self.assertRaises(csv.Error) as cm:
            mydialect()
        self.assertEqual(str(cm.exception),
                         '"lineterminator" must be a string') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_csv.py


示例9: test_dialect

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_dialect(self):
        data = """\
label1,label2,label3
index1,"a,c,e
index2,b,d,f
"""
        dia = csv.excel()
        dia.quoting = csv.QUOTE_NONE
        with tm.assert_produces_warning(ParserWarning):
            df = self.read_csv(StringIO(data), dialect=dia)
        data = '''\
label1,label2,label3
index1,a,c,e
index2,b,d,f
'''
        exp = self.read_csv(StringIO(data))
        exp.replace('a', '"a', inplace=True)
        tm.assert_frame_equal(df, exp) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:22,代码来源:dialect.py


示例10: test_null_quote_char

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_null_quote_char(self):
        data = 'a,b,c\n1,2,3'
        # sanity checks
        msg = 'quotechar must be set if quoting enabled'
        tm.assert_raises_regex(TypeError, msg, self.read_csv,
                               StringIO(data), quotechar=None,
                               quoting=csv.QUOTE_MINIMAL)
        tm.assert_raises_regex(TypeError, msg, self.read_csv,
                               StringIO(data), quotechar='',
                               quoting=csv.QUOTE_MINIMAL)
        # no errors should be raised if quoting is None
        expected = DataFrame([[1, 2, 3]],
                             columns=['a', 'b', 'c'])
        result = self.read_csv(StringIO(data), quotechar=None,
                               quoting=csv.QUOTE_NONE)
        tm.assert_frame_equal(result, expected)
        result = self.read_csv(StringIO(data), quotechar='',
                               quoting=csv.QUOTE_NONE)
        tm.assert_frame_equal(result, expected) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:27,代码来源:quoting.py


示例11: to_trec_eval_row

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def to_trec_eval_row(self, alternative_exp_name=None, page_only=False):
        exp_name_ = alternative_exp_name if alternative_exp_name is not  None \
                    else self.exp_name
        return [self.query_id, 'Q0', self.paragraph_id, self.rank, self.score, exp_name_]
#
# csv.register_dialect(
#     'trec_eval',
#     delimiter = ' ',
#     quotechar = '"',
#     doublequote = False,
#     skipinitialspace = False,
#     lineterminator = '\n',
#     quoting = csv.QUOTE_NONE)
#
#
# def configure_csv_writer(fileobj):
#     'Convenience method to create a csv writer with the trec_eval_dialect'
#     return csv.writer(fileobj, dialect='trec_eval')
# 
开发者ID:TREMA-UNH,项目名称:trec-car-tools,代码行数:22,代码来源:format_runs.py


示例12: test_write_arg_valid

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_write_arg_valid(self):
        self.assertRaises(csv.Error, self._write_test, None, '')
        self._write_test((), '')
        self._write_test([None], '""')
        self.assertRaises(csv.Error, self._write_test,
                          [None], None, quoting = csv.QUOTE_NONE)
        # Check that exceptions are passed up the chain
        class BadList:
            def __len__(self):
                return 10;
            def __getitem__(self, i):
                if i > 2:
                    raise IOError
        self.assertRaises(IOError, self._write_test, BadList(), '')
        class BadItem:
            def __str__(self):
                raise IOError
        self.assertRaises(IOError, self._write_test, [BadItem()], '') 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:20,代码来源:test_csv.py


示例13: test_write_escape

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_write_escape(self):
        self._write_test(['a',1,'p,q'], 'a,1,"p,q"',
                         escapechar='\\')
        self.assertRaises(csv.Error,
                          self._write_test,
                          ['a',1,'p,"q"'], 'a,1,"p,\\"q\\""',
                          escapechar=None, doublequote=False)
        self._write_test(['a',1,'p,"q"'], 'a,1,"p,\\"q\\""',
                         escapechar='\\', doublequote = False)
        self._write_test(['"'], '""""',
                         escapechar='\\', quoting = csv.QUOTE_MINIMAL)
        self._write_test(['"'], '\\"',
                         escapechar='\\', quoting = csv.QUOTE_MINIMAL,
                         doublequote = False)
        self._write_test(['"'], '\\"',
                         escapechar='\\', quoting = csv.QUOTE_NONE)
        self._write_test(['a',1,'p,q'], 'a,1,p\\,q',
                         escapechar='\\', quoting = csv.QUOTE_NONE) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:20,代码来源:test_csv.py


示例14: test_quoting

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_quoting(self):
        class mydialect(csv.Dialect):
            delimiter = ";"
            escapechar = '\\'
            doublequote = False
            skipinitialspace = True
            lineterminator = '\r\n'
            quoting = csv.QUOTE_NONE
        d = mydialect()
        mydialect.quoting = None
        self.assertRaises(csv.Error, mydialect)
        mydialect.doublequote = True
        mydialect.quoting = csv.QUOTE_ALL
        mydialect.quotechar = '"'
        d = mydialect()
        mydialect.quotechar = "''"
        self.assertRaises(csv.Error, mydialect)
        mydialect.quotechar = 4
        self.assertRaises(csv.Error, mydialect) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:25,代码来源:test_csv.py


示例15: test_dialect

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_dialect(self):
        data = """\
label1,label2,label3
index1,"a,c,e
index2,b,d,f
"""
        dia = csv.excel()
        dia.quoting = csv.QUOTE_NONE
        df = self.read_csv(StringIO(data), dialect=dia)
        data = '''\
label1,label2,label3
index1,a,c,e
index2,b,d,f
'''
        exp = self.read_csv(StringIO(data))
        exp.replace('a', '"a', inplace=True)
        tm.assert_frame_equal(df, exp) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:test_parsers.py


示例16: write_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def write_csv(self, path):
        with tempfile.NamedTemporaryFile() as f:
            # Write the DataFrame to the temporary file path
            if options.verbose:
                util.log(
                    'Writing DataFrame to temporary file {}'.format(f.name)
                )
            self.df.to_csv(
                f.name,
                header=False,
                index=False,
                sep=',',
                quoting=csv.QUOTE_NONE,
                escapechar='\\',
                na_rep='#NULL',
            )
            f.seek(0)
            if options.verbose:
                util.log('Writing CSV to: {0}'.format(path))
            self.hdfs.put(path, f.name)
        return path 
开发者ID:ibis-project,项目名称:ibis,代码行数:26,代码来源:pandas_interop.py


示例17: _celex

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def _celex(path,
           fields,
           lemmas,
           language):
    w_length, s_length = lengths[(language, lemmas)]
    _opener = partial(_celex_opener,
                      word_length=w_length,
                      struct_length=s_length)
    return reader(path,
                  fields,
                  PROJECT2FIELD[(language, lemmas)],
                  language,
                  delimiter="\\",
                  quoting=csv.QUOTE_NONE,
                  opener=_opener,
                  preprocessors={"phonology": phon_func,
                                 "syllables": syll_func}) 
开发者ID:clips,项目名称:wordkit,代码行数:20,代码来源:celex.py


示例18: index

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def index(sqlite_filename, tsv_filename):
    logger.info('Reading tsv file %s', tsv_filename)
    # https://stackoverflow.com/questions/15063936/csv-error-field-larger-than-field-limit-131072
    # https://github.com/balta2ar/brotab/issues/25
    # It should work on Python 3 and Python 2, on any CPU / OS.
    csv.field_size_limit(int(ctypes.c_ulong(-1).value // 2))
    with open(tsv_filename, encoding='utf-8') as tsv_file:
        lines = [tuple(line) for line in csv.reader(tsv_file, delimiter='\t',
                                                    quoting=csv.QUOTE_NONE)]
    logger.info(
        'Creating sqlite DB filename %s from tsv %s (%s lines)',
        sqlite_filename, tsv_filename, len(lines))
    conn = sqlite3.connect(sqlite_filename)
    cursor = conn.cursor()
    with suppress(sqlite3.OperationalError):
        cursor.execute('drop table tabs;')
    cursor.execute(
        'create virtual table tabs using fts5('
        '    tab_id, title, url, body, tokenize="porter unicode61");')
    cursor.executemany('insert into tabs values (?, ?, ?, ?)', lines)
    conn.commit()
    conn.close() 
开发者ID:balta2ar,项目名称:brotab,代码行数:26,代码来源:index.py


示例19: __parse_file

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def __parse_file(self):
        filename = self.options['filename']
        if not filename:
            raise IOError
        sep = self.options['column_separator']
        quote = self.options['quote_character']
        values = []
        with open(filename, newline='') as infile:
            # if sep is not a one character string, csv.reader will raise a TypeError
            if not quote:
                csvreader = csv.reader(infile, delimiter=str(sep), quoting=csv.QUOTE_NONE)
            else:
                csvreader = csv.reader(infile, delimiter=str(sep), quotechar=str(quote))
            # get each line from the file and separate it into columns based on sep
            for row in csvreader:
                # append all lines as-is case-wise
                values.append([value.strip() for value in row])
                # ensure the number of columns in each row is the same as the previous row
                if len(values) > 1:
                    assert len(values[-1]) == len(values[-2])
        return values 
开发者ID:lanmaster53,项目名称:recon-ng-marketplace,代码行数:26,代码来源:csv_file.py


示例20: test_write_arg_valid

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def test_write_arg_valid(self):
        self._write_error_test(csv.Error, None)
        self._write_test((), '')
        self._write_test([None], '""')
        self._write_error_test(csv.Error, [None], quoting = csv.QUOTE_NONE)
        # Check that exceptions are passed up the chain
        class BadList:
            def __len__(self):
                return 10;
            def __getitem__(self, i):
                if i > 2:
                    raise OSError
        self._write_error_test(OSError, BadList())
        class BadItem:
            def __str__(self):
                raise OSError
        self._write_error_test(OSError, [BadItem()]) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_csv.py


示例21: create_csv_file

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def create_csv_file(cls, full_path_file, content, delimiter=','):
        with open(full_path_file, 'w+') as u_file:
            writer = csv.writer(u_file, quoting=csv.QUOTE_NONE, delimiter=delimiter)
            writer.writerows(content) 
开发者ID:apache,项目名称:incubator-spot,代码行数:6,代码来源:utils.py


示例22: _get_vocab_freqs

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONE [as 别名]
def _get_vocab_freqs():
  """Returns vocab frequencies.
  Returns:
    List of integers, length=FLAGS.vocab_size.
  Raises:
    ValueError: if the length of the frequency file is not equal to the vocab
      size, or if the file is not found.
  """
  path = FLAGS.vocab_freq_path or os.path.join(FLAGS.data_dir, 'vocab_freq.txt')
  if tf.gfile.Exists(path):
    with tf.gfile.Open(path) as f:
      # Get pre-calculated frequencies of words.
      reader = csv.reader(f, quoting=csv.QUOTE_NONE)
      freqs = [int(row[-1]) for row in reader]
      if len(freqs) != FLAGS.vocab_size:
        raise ValueError('Frequency file length %d != vocab size %d' %
                         (len(freqs), FLAGS.vocab_size))
  else:
    if FLAGS.vocab_freq_path:
      raise ValueError('vocab_freq_path not found')
    freqs = [1] * FLAGS.vocab_size
  return freqs 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:28,代码来源:graphs.py



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