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


Python csv.QUOTE_NONNUMERIC屬性代碼示例

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


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


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