Created
December 7, 2023 18:12
-
-
Save mmkhitaryan/26e7f451f741ee08ece05a927311fc90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
pid_to_command_line = {} | |
list_of_all_processes = [] | |
import csv | |
field_names = None | |
with open('task5.csv', 'r') as csv_file: | |
csv_reader = csv.DictReader(csv_file) | |
field_names = csv_reader.fieldnames | |
seen_pids = [] | |
for row in csv_reader: | |
pid_to_command_line[row['process.pid']] = row['process.command_line'] | |
list_of_all_processes.append(row) | |
for process in list_of_all_processes: | |
process['process.parent.command_line'] = pid_to_command_line.get( process['process.parent.pid'] ) | |
field_names.append( 'process.parent.command_line' ) | |
with open('task5_result.csv', 'w', newline='') as csv_file: | |
# Create a DictWriter | |
csv_writer = csv.DictWriter(csv_file, fieldnames=field_names) | |
# Write the header | |
csv_writer.writeheader() | |
# Write the data | |
csv_writer.writerows(list_of_all_processes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment