mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-04-01 11:22:48 +00:00
- Ignore duplicate aggregate DMARC reports with the same `org_name` and `report_id` seen within the same hour ([#539](https://github.com/domainaware/parsedmarc/issues/539)) - Fix saving SMTP TLS reports to OpenSearch (PR #585 closed issue #576) - Add 303 entries to `base_reverse_dns_map.csv`
26 lines
617 B
Python
Executable File
26 lines
617 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import glob
|
|
import csv
|
|
|
|
|
|
maps_dir = os.path.join("parsedmarc","resources", "maps")
|
|
csv_files = glob.glob(os.path.join(maps_dir, "*.csv"))
|
|
|
|
|
|
def sort_csv(filepath, column=0):
|
|
with open(filepath, mode="r", newline="") as infile:
|
|
reader = csv.reader(infile)
|
|
header = next(reader)
|
|
sorted_rows = sorted(reader, key=lambda row: row[column])
|
|
|
|
with open(filepath, mode="w", newline="\n") as outfile:
|
|
writer = csv.writer(outfile)
|
|
writer.writerow(header)
|
|
writer.writerows(sorted_rows)
|
|
|
|
|
|
for csv_file in csv_files:
|
|
sort_csv(csv_file)
|