當前位置: 首頁>>代碼示例>>Python>>正文


Python csv.QUOTE_NONE屬性代碼示例

本文整理匯總了Python中csv.QUOTE_NONE屬性的典型用法代碼示例。如果您正苦於以下問題:Python csv.QUOTE_NONE屬性的具體用法?Python csv.QUOTE_NONE怎麽用?Python csv.QUOTE_NONE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在csv的用法示例。


在下文中一共展示了csv.QUOTE_NONE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的csv.QUOTE_NONE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。