Jan-05-2020, 10:24 AM
I am using the following code write a CSV file from a List containing Dictionaries
When I run it on my Mac it is fine, but when I run it on a PC I get blank rows between each data line. Why is this? I had to add the utf-8 otherwise the Windows file path did not work. Is this related to the issue?
Thanks in advance.
When I run it on my Mac it is fine, but when I run it on a PC I get blank rows between each data line. Why is this? I had to add the utf-8 otherwise the Windows file path did not work. Is this related to the issue?
def print_report(): order = ['id', 'Sub Estate', 'hostname', 'type', 'os', 'lastSeenAt', 'Last_Seen', 'health', 'threats', 'service_health', 'tamperProtectionEnabled', 'ipv4Addresses', 'associatedPerson'] with open(report_path, 'w', encoding='utf-8') as output_file: dict_writer = csv.DictWriter(output_file, order) dict_writer.writeheader() dict_writer.writerows(computer_list)Also, I would like to only output some of these keys. Is there a way to do this or do I have output them all?
Thanks in advance.