Python csv.QUOTE_NONNUMERIC属性代码示例

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

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

示例1: get_denominator_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def get_denominator_csv(self):
        output = io.StringIO()
        writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
        writer.writerow(["year", "month", "officers out on service"])
        values = sorted(self.denominator_values,
                        key=lambda x: (x.year, x.month))
        for value in values:
            row = [
                value.year,
                value.month,
                value.officers_out_on_service
            ]
            writer.writerow(row)
        return output.getvalue() 
开发者ID:codeforamerica,项目名称:comport,代码行数:21,代码来源:models.py


示例2: writerow

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def writerow(self, row):
            def _check_as_is(x):
                return (self.quoting == csv.QUOTE_NONNUMERIC and
                        is_number(x)) or isinstance(x, str)
            row = [x if _check_as_is(x)
                   else pprint_thing(x).encode("utf-8") for x in row]
            self.writer.writerow([s for s in row])
            # Fetch UTF-8 output from the queue ...
            data = self.queue.getvalue()
            data = data.decode("utf-8")
            # ... and re-encode it into the target encoding
            data = self.encoder.encode(data)
            # write to the target stream
            self.stream.write(data)
            # empty queue
            self.queue.truncate(0) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:common.py


示例3: writerows

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def writerows(self, rows):
            def _check_as_is(x):
                return (self.quoting == csv.QUOTE_NONNUMERIC and
                        is_number(x)) or isinstance(x, str)
            for i, row in enumerate(rows):
                rows[i] = [x if _check_as_is(x)
                           else pprint_thing(x).encode("utf-8") for x in row]
            self.writer.writerows([[s for s in row] for row in rows])
            # Fetch UTF-8 output from the queue ...
            data = self.queue.getvalue()
            data = data.decode("utf-8")
            # ... and re-encode it into the target encoding
            data = self.encoder.encode(data)
            # write to the target stream
            self.stream.write(data)
            # empty queue
            self.queue.truncate(0) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:common.py


示例4: writerow

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def writerow(self, row):
            def _check_as_is(x):
                return (self.quoting == csv.QUOTE_NONNUMERIC and
                        is_number(x)) or isinstance(x, str)
            row = [x if _check_as_is(x)
                   else pprint_thing(x).encode('utf-8') for x in row]
            self.writer.writerow([s for s in row])
            # Fetch UTF-8 output from the queue ...
            data = self.queue.getvalue()
            data = data.decode("utf-8")
            # ... and reencode it into the target encoding
            data = self.encoder.encode(data)
            # write to the target stream
            self.stream.write(data)
            # empty queue
            self.queue.truncate(0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:20,代码来源:common.py


示例5: writerows

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def writerows(self, rows):
            def _check_as_is(x):
                return (self.quoting == csv.QUOTE_NONNUMERIC and
                        is_number(x)) or isinstance(x, str)
            for i, row in enumerate(rows):
                rows[i] = [x if _check_as_is(x)
                           else pprint_thing(x).encode('utf-8') for x in row]
            self.writer.writerows([[s for s in row] for row in rows])
            # Fetch UTF-8 output from the queue ...
            data = self.queue.getvalue()
            data = data.decode("utf-8")
            # ... and reencode it into the target encoding
            data = self.encoder.encode(data)
            # write to the target stream
            self.stream.write(data)
            # empty queue
            self.queue.truncate(0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:common.py


示例6: save_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def save_csv(matrix, output_directory, output_file_name):
    """
        Saves the input matrix as a CSV File
    Args:
        matrix(list):  an array containing data to be saved
        output_drectory(str): location to save graph
        output_file_name(str): name of the csv file to be saved
    Returns:
       null
    """
    if config.DEBUGGER:
        print "Generating", (output_file_name + ".csv")
    check_if_dir_exists(output_directory) #create output directory if doesn't exist
    output_file = output_directory + "/" + output_file_name +".csv"
    with open(output_file, 'wb') as myfile:
        wr = csv.writer(myfile, quoting=csv.QUOTE_NONNUMERIC)
        if matrix is not None:
            for col in matrix:
                wr.writerow(col) 
开发者ID:prasadtalasila,项目名称:IRCLogParser,代码行数:24,代码来源:saver.py


示例7: setup_writer

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def setup_writer(fileid, postfix):
    """Use to prepare file and writer for data logging
    Arguments:
        fileid (string): unique file identfier
        postfix (string): path
    """
    # we dump episode num, step, total reward, and
    # number of episodes solved in a csv file for analysis
    csvfilename = "%s.csv" % fileid
    csvfilename = os.path.join(postfix, csvfilename)
    csvfile = open(csvfilename, 'w', 1)
    writer = csv.writer(csvfile,
                        delimiter=',',
                        quoting=csv.QUOTE_NONNUMERIC)
    writer.writerow(['Episode',
                     'Step',
                     'Total Reward',
                     'Number of Episodes Solved'])
    return csvfile, writer 
开发者ID:PacktPublishing,项目名称:Advanced-Deep-Learning-with-Keras,代码行数:22,代码来源:policygradient-car-10.1.1.py


示例8: gen_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def gen_csv(csvdata):
    headerline = csvdata[0].keys()
    if PY3:
        output = io.StringIO()
    else:
        output = io.BytesIO()
        headerline = [l.encode('utf-8') for l in headerline]
    writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
    writer.writerow(headerline)
    for rk in csvdata:
        rkline = []
        for l in rk.values():
            if l is None:
                rkline.append("")
            elif isinstance(l, (int, float, datetime)):
                rkline.append(l)
            else:
                rkline.append(l.encode('utf-8'))
        writer.writerow(rkline)
    return output.getvalue()
# ------ EVENT INFORMATION ---------
# API: Outputs JSON about the current event 
开发者ID:hackathons-ftw,项目名称:dribdat,代码行数:26,代码来源:api.py


示例9: openPDF

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def openPDF(path, data):
    return
# def openCSV(path, data):
#     path = input("\n\tEnter the name of the text and extension of the text, CSV, or PDF file (has to be in same directory) to be mass analyzed in Emote: ")
#     try:
#         with open(path) as csvfile:
#             reader = csv.reader(csvfile, dialect='excel', quoting=csv.QUOTE_NONNUMERIC)
#             datalist = []
#             datalist = list(reader)
#             return datalist
#     except IOError as err:
#         print("Error opening path to file.")
#     startInterface()
#     return 
开发者ID:jddunn,项目名称:emoter,代码行数:18,代码来源:emote_trainer.py


示例10: dump

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def dump(self):
        """
        :param saveto:
        :return:
        """
        filePath = self.csvFilePath
        isCsvExists = os.path.exists(filePath)
        data = self.data
        fields = self.fields
        with open(filePath, 'a') as f:
            wr = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC)
            if not isCsvExists:
                # 新文件,需要写入表头
                wr.writerow(fields)
            for d in data:
                # 写入数据
                wr.writerow(d.values()) 
开发者ID:lamter,项目名称:cfmmc,代码行数:22,代码来源:table.py


示例11: d_to_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def d_to_csv(d, with_header=True, carriage_return=True):
    df = []
    results = d["results"]
    if results:
        header = sorted(results[0].keys())
        if with_header:
            df.append(["query"] + header)
    for res in results:
        row = [d["query"]]
        for key in header:
            row.append(res[key])
        df.append(row)
    output = io.StringIO()
    writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
    for row in df:
        writer.writerow(row)
    csv_string = output.getvalue()
    if carriage_return:
        return csv_string
    else:
        return csv_string[:-1] 
开发者ID:Phelimb,项目名称:BIGSI,代码行数:25,代码来源:__main__.py


示例12: save_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def save_csv (prefix='data'):
    # Dump the ChangeSets
    if len(ChangeSets) > 0:
        fd = open('%s-changesets.csv' % prefix, 'w')
        writer = csv.writer (fd, quoting=csv.QUOTE_NONNUMERIC)
        writer.writerow (['Commit', 'Date', 'Domain',
                          'Email', 'Name', 'Affliation',
                          'Added', 'Removed'])
        for commit in ChangeSets:
            writer.writerow(commit)
    # Dump the file types
    if len(FileTypes) > 0:
        fd = open('%s-filetypes.csv' % prefix, 'w')
        writer = csv.writer (fd, quoting=csv.QUOTE_NONNUMERIC)
        writer.writerow (['Commit', 'Type', 'Added', 'Removed'])
        for commit in FileTypes:
            writer.writerow(commit) 
开发者ID:mendersoftware,项目名称:integration,代码行数:21,代码来源:csvdump.py


示例13: get_csv_stats

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def get_csv_stats(stats, recorded_cols=None):
    """
    Create a CSV buffer from the stats DataFrame.
    Parameters
    ----------
    path: str
    stats: list[Object]
    recorded_cols: list[str]
    Returns
    -------
    """
    df, columns = prepare_stats(stats, recorded_cols=recorded_cols)
    return df.to_csv(
        None,
        columns=columns,
        # encoding='utf-8',
        quoting=csv.QUOTE_NONNUMERIC
    ).encode() 
开发者ID:enigmampc,项目名称:catalyst,代码行数:24,代码来源:stats_utils.py


示例14: update_subjects_context_open_context_db

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def update_subjects_context_open_context_db(
    project_uuid=PROJECT_UUID,
    source_prefix=SOURCE_ID_PREFIX,
    load_files=DESTINATION_PATH,
    all_contexts_file=FILENAME_ALL_CONTEXTS,
    loaded_contexts_file=FILENAME_LOADED_CONTEXTS,
):
    """Loads subjects, contexts items and containment relations"""
    all_contexts_df = pd.read_csv((load_files + all_contexts_file))
    new_contexts_df = update_contexts_subjects(
        project_uuid,
        (source_prefix + all_contexts_file),
        all_contexts_df
    )
    loaded_contexts_path = (load_files + loaded_contexts_file)
    new_contexts_df.to_csv(
        loaded_contexts_path,
        index=False,
        quoting=csv.QUOTE_NONNUMERIC
    ) 
开发者ID:ekansa,项目名称:open-context-py,代码行数:22,代码来源:etl.py


示例15: update_link_rel_open_context_db

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def update_link_rel_open_context_db(
    project_uuid=PROJECT_UUID,
    source_prefix=SOURCE_ID_PREFIX,
    load_files=DESTINATION_PATH,
    link_sources=LINK_RELATIONS_SOURCES,
    loaded_link_file_prefix='loaded--',
):
    """Loads linking relationships into the database"""
    for source_id, filename in link_sources:
        df = pd.read_csv((load_files + filename))
        df = load_link_relations_df_into_oc(
            project_uuid,
            source_id,
            df
        )
        df.to_csv(
            (load_files + loaded_link_file_prefix + filename),
            index=False,
            quoting=csv.QUOTE_NONNUMERIC
        ) 
开发者ID:ekansa,项目名称:open-context-py,代码行数:22,代码来源:etl.py


示例16: __init__

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def __init__(self, f, dialect=None, encoding='utf-8', errors='strict',
                 **kwds):
        format_params = ['delimiter', 'doublequote', 'escapechar',
                         'lineterminator', 'quotechar', 'quoting',
                         'skipinitialspace']
        if dialect is None:
            if not any([kwd_name in format_params
                        for kwd_name in kwds.keys()]):
                dialect = csv.excel
        self.reader = csv.reader(f, dialect, **kwds)
        self.encoding = encoding
        self.encoding_errors = errors
        self._parse_numerics = bool(
            self.dialect.quoting & csv.QUOTE_NONNUMERIC) 
开发者ID:eirannejad,项目名称:pyRevit,代码行数:18,代码来源:py2.py


示例17: clear

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def clear(filename):
    rows = []
    with open(filename, 'rb') as csvfile:
        reader = csv.reader(csvfile, delimiter=';')
        rows = [row for row in reader]
    with open(filename, 'wb') as csvfile:
        writer = csv.writer(csvfile, delimiter=';', quotechar='"', skipinitialspace=True,
                            quoting=csv.QUOTE_NONNUMERIC)  # QUOTE_MINIMAL vs QUOTE_NONNUMERIC
        for row in rows:
            if not row[0].startswith("#"):
                # удаляем неразрывные пробелы в названиях категорий
                row[2] = row[2].strip(' ')
                writer.writerow(row) 
开发者ID:ohbobbyboy,项目名称:bobby_boy,代码行数:18,代码来源:report.py


示例18: writerow

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def writerow(self, row):
            def _check_as_is(x):
                return (self.quoting == csv.QUOTE_NONNUMERIC and
                        is_number(x)) or isinstance(x, str)
            row = [x if _check_as_is(x)
                   else pprint_thing(x).encode("utf-8") for x in row]
            self.writer.writerow([s for s in row])
            # Fetch UTF-8 output from the queue ...
            data = self.queue.getvalue()
            data = data.decode("utf-8")
            # ... and reencode it into the target encoding
            data = self.encoder.encode(data)
            # write to the target stream
            self.stream.write(data)
            # empty queue
            self.queue.truncate(0) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:20,代码来源:common.py


示例19: writerows

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def writerows(self, rows):
            def _check_as_is(x):
                return (self.quoting == csv.QUOTE_NONNUMERIC and
                        is_number(x)) or isinstance(x, str)
            for i, row in enumerate(rows):
                rows[i] = [x if _check_as_is(x)
                           else pprint_thing(x).encode("utf-8") for x in row]
            self.writer.writerows([[s for s in row] for row in rows])
            # Fetch UTF-8 output from the queue ...
            data = self.queue.getvalue()
            data = data.decode("utf-8")
            # ... and reencode it into the target encoding
            data = self.encoder.encode(data)
            # write to the target stream
            self.stream.write(data)
            # empty queue
            self.queue.truncate(0) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:21,代码来源:common.py


示例20: get_uof_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def get_uof_csv(self):
        output = io.StringIO()
        writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
        uof_class = getattr(importlib.import_module("comport.data.models"), "UseOfForceIncident{}".format(self.short_name))
        csv_schema = uof_class.get_csv_schema()
        csv_headers = [col[0] for col in csv_schema]
        csv_vars = [col[1] for col in csv_schema]
        writer.writerow(csv_headers)
        use_of_force_incidents = uof_class.query.all()
        for incident in use_of_force_incidents:
            values = []
            for incident_var in csv_vars:
                incident_value = getattr(incident, incident_var)
                if incident_var.endswith("_date"):
                    incident_value = coalesce_date(incident_value)
                values.append(incident_value)
            writer.writerow(values)
        return output.getvalue() 
开发者ID:codeforamerica,项目名称:comport,代码行数:28,代码来源:models.py


示例21: get_ois_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def get_ois_csv(self):
        output = io.StringIO()
        writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
        ois_class = getattr(importlib.import_module("comport.data.models"), "OfficerInvolvedShooting{}".format(self.short_name))
        csv_schema = ois_class.get_csv_schema()
        csv_headers = [col[0] for col in csv_schema]
        csv_vars = [col[1] for col in csv_schema]
        writer.writerow(csv_headers)
        officer_involved_shootings = ois_class.query.all()
        for incident in officer_involved_shootings:
            values = []
            for incident_var in csv_vars:
                incident_value = getattr(incident, incident_var)
                if incident_var.endswith("_date"):
                    incident_value = coalesce_date(incident_value)
                values.append(incident_value)
            writer.writerow(values)
        return output.getvalue() 
开发者ID:codeforamerica,项目名称:comport,代码行数:28,代码来源:models.py


示例22: get_complaint_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def get_complaint_csv(self):
        output = io.StringIO()
        writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
        complaint_class = getattr(importlib.import_module("comport.data.models"), "CitizenComplaint{}".format(self.short_name))
        csv_schema = complaint_class.get_csv_schema()
        csv_headers = [col[0] for col in csv_schema]
        csv_vars = [col[1] for col in csv_schema]
        writer.writerow(csv_headers)
        complaints = complaint_class.query.all()
        for complaint in complaints:
            values = []
            for incident_var in csv_vars:
                incident_value = getattr(complaint, incident_var)
                if incident_var.endswith("_date"):
                    incident_value = coalesce_date(incident_value)
                values.append(incident_value)
            writer.writerow(values)
        return output.getvalue() 
开发者ID:codeforamerica,项目名称:comport,代码行数:28,代码来源:models.py


示例23: get_pursuits_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def get_pursuits_csv(self):
        output = io.StringIO()
        writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
        pursuits_class = getattr(importlib.import_module("comport.data.models"), "Pursuit{}".format(self.short_name))
        csv_schema = pursuits_class.get_csv_schema()
        csv_headers = [col[0] for col in csv_schema]
        csv_vars = [col[1] for col in csv_schema]
        writer.writerow(csv_headers)
        incidents = pursuits_class.query.all()
        for incident in incidents:
            values = []
            for incident_var in csv_vars:
                incident_value = getattr(incident, incident_var)
                if incident_var.endswith("_date"):
                    incident_value = coalesce_date(incident_value)
                values.append(incident_value)
            writer.writerow(values)
        return output.getvalue() 
开发者ID:codeforamerica,项目名称:comport,代码行数:28,代码来源:models.py


示例24: get_assaults_csv

# 需要导入模块: import csv [as 别名]
# 或者: from csv import QUOTE_NONNUMERIC [as 别名]
def get_assaults_csv(self):
        output = io.StringIO()
        writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC)
        assaults_class = getattr(importlib.import_module("comport.data.models"), "AssaultOnOfficer{}".format(self.short_name))
        csv_schema = assaults_class.get_csv_schema()
        csv_headers = [col[0] for col in csv_schema]
        csv_vars = [col[1] for col in csv_schema]
        writer.writerow(csv_headers)
        incidents = assaults_class.query.all()
        for incident in incidents:
            values = []
            for incident_var in csv_vars:
                incident_value = getattr(incident, incident_var)
                if incident_var.endswith("_date"):
                    incident_value = coalesce_date(incident_value)
                values.append(incident_value)
            writer.writerow(values)
        return output.getvalue() 
开发者ID:codeforamerica,项目名称:comport,代码行数:28,代码来源:models.py



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