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()
评论列表
文章目录