headers = ['_last_changed', 'this_is_string', 'this_is_int'<etc>]
converted_file = open(converted_file_path, 'w+', encoding='utf-8', newline='')
csv_writer = csv.DictWriter(converted_file, fieldnames=headers, delimiter=';',quoting=csv.QUOTE_NONNUMERIC)
csv_writer.writeheader()
for line in raw_file:
ioc = json.loads(line)
mp_line = [
datetime.now().strftime("%d.%m.%Y %H:%M:%S"), # DateTime
ioc['ip']['str'], # String
int(ioc['ip']['num']) if ioc['ip']['num'] else 'null' #Integer
]
mp_csv_dict = dict(zip(headers, mp_line))
csv_writer.writerow(mp_csv_dict)
converted_file.close()