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


Python csv.QUOTE_ALL属性代码示例

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


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

示例1: liststore_to_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def liststore_to_csv(store, target_file, columns):
	"""
	Write the contents of a :py:class:`Gtk.ListStore` to a csv file.

	:param store: The store to export the information from.
	:type store: :py:class:`Gtk.ListStore`
	:param str target_file: The destination file for the CSV data.
	:param dict columns: A dictionary mapping store column ids to the value names.
	:return: The number of rows that were written.
	:rtype: int
	"""
	target_file_h = open(target_file, 'w')
	writer = csv.writer(target_file_h, quoting=csv.QUOTE_ALL)
	rows = liststore_export(store, columns, _csv_write, (writer,))
	target_file_h.close()
	return rows 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:18,代码来源:export.py

示例2: _test_arg_valid

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def _test_arg_valid(self, ctor, arg):
        self.assertRaises(TypeError, ctor)
        self.assertRaises(TypeError, ctor, None)
        self.assertRaises(TypeError, ctor, arg, bad_attr = 0)
        self.assertRaises(TypeError, ctor, arg, delimiter = 0)
        self.assertRaises(TypeError, ctor, arg, delimiter = 'XX')
        self.assertRaises(csv.Error, ctor, arg, 'foo')
        self.assertRaises(TypeError, ctor, arg, delimiter=None)
        self.assertRaises(TypeError, ctor, arg, delimiter=1)
        self.assertRaises(TypeError, ctor, arg, quotechar=1)
        self.assertRaises(TypeError, ctor, arg, lineterminator=None)
        self.assertRaises(TypeError, ctor, arg, lineterminator=1)
        self.assertRaises(TypeError, ctor, arg, quoting=None)
        self.assertRaises(TypeError, ctor, arg,
                          quoting=csv.QUOTE_ALL, quotechar='')
        self.assertRaises(TypeError, ctor, arg,
                          quoting=csv.QUOTE_ALL, quotechar=None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_csv.py

示例3: _test_dialect_attrs

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def _test_dialect_attrs(self, ctor, *args):
        # Now try with dialect-derived options
        class dialect:
            delimiter='-'
            doublequote=False
            escapechar='^'
            lineterminator='$'
            quotechar='#'
            quoting=csv.QUOTE_ALL
            skipinitialspace=True
            strict=False
        args = args + (dialect,)
        obj = ctor(*args)
        self.assertEqual(obj.dialect.delimiter, '-')
        self.assertEqual(obj.dialect.doublequote, False)
        self.assertEqual(obj.dialect.escapechar, '^')
        self.assertEqual(obj.dialect.lineterminator, "$")
        self.assertEqual(obj.dialect.quotechar, '#')
        self.assertEqual(obj.dialect.quoting, csv.QUOTE_ALL)
        self.assertEqual(obj.dialect.skipinitialspace, True)
        self.assertEqual(obj.dialect.strict, False) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_csv.py

示例4: test_quoting

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [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

示例5: writeToCsv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def writeToCsv(backup_list, application_list, output_file, logger):

    backup_csv = output_file + "Backups.csv"
    app_csv = output_file + "Applications.csv"


    with open(backup_csv, 'w', newline='') as backup_csv_handle:
        columns = ["Device_Name", "Product_Name", "Product_Model", "Phone_Number",
                "iOS_Version", "Last_Backup_Completion",
                "Last_Backup_Write_Completed", "User_Computers", "Passcode_Set", "Encrypted",
                "GUID", "ICCID", "IMEI", "MEID", "Serial_Num",
                "Full_Backup", "Version", "iTunes_Version"]
        wr = csv.writer(backup_csv_handle, quoting=csv.QUOTE_ALL)
        wr.writerows([columns, backup_list])

    with open(app_csv, 'w', newline='') as app_csv_handle:
        columns = ["Device_Name", "Device_SN", "App_Name", "AppleID", "User_Full_Name", "Purchase_Date",
                   "Is_Possibly_Sideloaded", "App_Version", "Is_Auto_Download", "Is_Purchased_Redownload",
                   "Publisher", "Full_App_Name"]
        wr = csv.writer(app_csv_handle, quoting=csv.QUOTE_ALL)
        wr.writerow(columns)
        wr.writerows(application_list) 
开发者ID:jfarley248,项目名称:iTunes_Backup_Reader,代码行数:24,代码来源:writer.py

示例6: _tabulate

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def _tabulate(output, headers, fmt):
    fmt = fmt or git_config('pw.format') or 'table'

    if fmt == 'table':
        return tabulate(output, headers, tablefmt='psql')
    elif fmt == 'simple':
        return tabulate(output, headers, tablefmt='simple')
    elif fmt == 'csv':
        result = six.StringIO()
        writer = csv.writer(
            result, quoting=csv.QUOTE_ALL, lineterminator=os.linesep)
        writer.writerow([ensure_str(h) for h in headers])
        for item in output:
            writer.writerow([ensure_str(i) for i in item])
        return result.getvalue()

    print('pw.format must be one of: table, simple, csv')
    sys.exit(1) 
开发者ID:getpatchwork,项目名称:git-pw,代码行数:20,代码来源:utils.py

示例7: from_data

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def from_data(self, fields, rows):
        fp = StringIO()
        writer = csv.writer(fp, quoting=csv.QUOTE_ALL)

        writer.writerow([name.encode('utf-8') for name in fields])

        for data in rows:
            row = []
            for d in data:
                if isinstance(d, basestring):
                    d = d.replace('\n',' ').replace('\t',' ')
                    try:
                        d = d.encode('utf-8')
                    except UnicodeError:
                        pass
                if d is False: d = None
                row.append(d)
            writer.writerow(row)

        fp.seek(0)
        data = fp.read()
        fp.close()
        return data 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:25,代码来源:main.py

示例8: download_data

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def download_data(request, project_pk):
    """This function gets the labeled data and makes it available for download

    Args:
        request: The POST request
        project_pk: Primary key of the project
    Returns:
        an HttpResponse containing the requested data
    """
    project = Project.objects.get(pk=project_pk)
    data, labels = get_labeled_data(project)
    data = data.to_dict("records")

    buffer = io.StringIO()
    wr = csv.DictWriter(buffer, fieldnames=['ID', 'Text', 'Label'], quoting=csv.QUOTE_ALL)
    wr.writeheader()
    wr.writerows(data)
    buffer.seek(0)
    response = HttpResponse(buffer, content_type='text/csv')
    response['Content-Disposition'] = 'attachment;'

    return response 
开发者ID:RTIInternational,项目名称:SMART,代码行数:24,代码来源:api.py

示例9: module_run

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def module_run(self):
        badcharacters = ['@', '-', '=', '+']
        filename = self.options['filename']
        # codecs module not used because the csv module converts to ASCII
        with open(filename, 'w') as outfile:
            table = self.options['table']
            csvwriter = csv.writer(outfile, quoting=csv.QUOTE_ALL)
            if self.options['headers']:
                columns = [c[0] for c in self.get_columns(table)]
                csvwriter.writerow(columns)
            cnt = 0
            rows = self.query(f'SELECT * FROM "{table}" ORDER BY 1')
            for row in rows:
                row = [x if x else '' for x in row]
                if any(row):
                    cnt += 1
                    # prevent csv injection
                    sanitized_row = []
                    for cell in row:
                        if cell and cell[0] in badcharacters:
                            cell = ' '+cell
                        sanitized_row.append(cell)
                    csvwriter.writerow(sanitized_row)
        self.output(f"{cnt} records added to '{filename}'.") 
开发者ID:lanmaster53,项目名称:recon-ng-marketplace,代码行数:26,代码来源:csv.py

示例10: __init__

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def __init__(self,filename,hashtype):
        """

        :param filename:
        :param hashtype:
        """
        try:

            self.csvfile = open(filename,'w')
            self.writer = csv.writer(self.csvfile,delimiter=",",quoting=csv.QUOTE_ALL)
            self.writer.writerow(('File','Path','Size','Modified Time','Access Time','Created Time','hashType','Owner','Group','Mode'))
        except :
            log.error("CSV store failed for "+filename) 
开发者ID:girishramnani,项目名称:hacking-tools,代码行数:15,代码来源:_pfish_tools.py

示例11: __init__

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def __init__(self, http, xmlRepGenerator):
        Attack.__init__(self, http, xmlRepGenerator)
        user_config_dir = os.getenv('HOME') or os.getenv('USERPROFILE')
        user_config_dir += "/config"
        if not os.path.isdir(user_config_dir):
            os.makedirs(user_config_dir)
        try:
            fd = open(os.path.join(user_config_dir, self.CONFIG_FILE))
            reader = csv.reader(fd)
            self.nikto_db = [l for l in reader if l != [] and l[0].isdigit()]
            fd.close()
        except IOError:
            try:
                print(_("Problem with local nikto database."))
                print(_("Downloading from the web..."))
                nikto_req = HTTP.HTTPResource("http://cirt.net/nikto/UPDATES/2.1.5/db_tests")
                resp = self.HTTP.send(nikto_req)
                page = resp.getRawPage()

                csv.register_dialect("nikto", quoting=csv.QUOTE_ALL, doublequote=False, escapechar="\\")
                reader = csv.reader(page.split("\n"), "nikto")
                self.nikto_db = [l for l in reader if l != [] and l[0].isdigit()]

                fd = open(os.path.join(user_config_dir, self.CONFIG_FILE), "w")
                writer = csv.writer(fd)
                writer.writerows(self.nikto_db)
                fd.close()
            except socket.timeout:
                print(_("Error downloading Nikto database")) 
开发者ID:flipkart-incubator,项目名称:watchdog,代码行数:31,代码来源:mod_nikto.py

示例12: savearduinolist

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def savearduinolist(self,filename, arduinolist):
        with open(filename, 'wb') as f:
            wr = csv.writer(f, quoting=csv.QUOTE_ALL)
            for row in arduinolist:
                wr.writerow(row) 
开发者ID:geomagpy,项目名称:magpy,代码行数:7,代码来源:arduinoprotocol.py

示例13: saveowlist

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def saveowlist(self,filename, owlist):
            with open(filename, 'wb') as f:
                wr = csv.writer(f, quoting=csv.QUOTE_ALL)
                for row in owlist:
                    wr.writerow(row) 
开发者ID:geomagpy,项目名称:magpy,代码行数:7,代码来源:owprotocol.py

示例14: _get_llavedelsaber_reader

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def _get_llavedelsaber_reader(self, source):
        return csv.DictReader(source, delimiter=';', quoting=csv.QUOTE_ALL) 
开发者ID:ideascube,项目名称:ideascube,代码行数:4,代码来源:forms.py

示例15: listNetworkClients

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_ALL [as 别名]
def listNetworkClients(aiomeraki: meraki.aio.AsyncDashboardAPI, folder_name, network):
    print(f'Finding clients in network {network["name"]}')
    try:
        # Get list of clients on network, filtering on timespan of last 14 days
        clients = await aiomeraki.clients.getNetworkClients(
            network["id"],
            timespan=60 * 60 * 24 * 14,
            perPage=1000,
            total_pages="all",
        )
    except meraki.AsyncAPIError as e:
        print(f"Meraki API error: {e}")
    except Exception as e:
        print(f"some other error: {e}")
    else:
        if clients:
            # Write to file
            file_name = f'{network["name"]}.csv'
            output_file = open(
                f"{folder_name}/{file_name}", mode="w", newline="\n"
            )
            field_names = clients[0].keys()
            csv_writer = csv.DictWriter(
                output_file,
                field_names,
                delimiter=",",
                quotechar='"',
                quoting=csv.QUOTE_ALL,
            )
            csv_writer.writeheader()
            csv_writer.writerows(clients)
            output_file.close()
            print(
                f"Successfully output {len(clients)} clients' data to file {file_name}"
            )
            return network["name"], field_names
    return network["name"], None 
开发者ID:meraki,项目名称:dashboard-api-python,代码行数:39,代码来源:aio_org_wide_clients_v0.py


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