nrt.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:ti-data-samples 作者: bom4v 项目源码 文件源码
def init_csv_file (csv_file_param):
    """
    Add the list of flattened event structures into the CSV file
    """
    csv_file = None
    if isinstance (csv_file_param, str):
        # The parameter is a file-path
        csv_file = open (csv_file_param, 'w', newline = '')

    elif hasattr (csv_file_param, 'write'):
        # The parameter is already a file (normally, stdout)
        csv_file = csv_file_param

    else:
        # Unknown
        raise IOError ('[Error] Output file parameter "' + str(csv_file_param) + '" unkown')

    # Write the header
    fileWriter = csv.DictWriter (csv_file, delimiter='^',
                                 fieldnames = fieldnames,
                                 dialect = 'unix', quoting = csv.QUOTE_NONE)

    #
    fileWriter.writeheader()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号