Crude implementation of CHIRP csv bookmarks import

This commit is contained in:
D0han 2019-09-30 01:18:10 +02:00
parent 774b71f8f0
commit 0b0fbd76a7

30
tools/bookmark_integrator Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python3
import json
import csv
import sys
from pprint import pprint
with open("../bookmarks.json") as f:
bookmarks = json.load(f)
modulation_map = {"FM": "nfm", "NFM": "nfm"}
in_file = sys.argv[1]
to_integrate = []
with open(in_file) as f:
reader = csv.DictReader(f)
for row in reader:
channel = {
"name": row["Name"],
"frequency": int(float(row["Frequency"]) * 1000000),
"modulation": modulation_map[row["Mode"]],
}
to_integrate.append(channel)
bookmarks.extend(to_integrate)
deduplicated = [dict(t) for t in {tuple(d.items()) for d in bookmarks}]
with open("../bookmarks.json", "w") as f:
json.dump(deduplicated, f)