-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgqrx2pss.py
executable file
·91 lines (76 loc) · 3.3 KB
/
gqrx2pss.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/python3
'''
____ ____ ____ ____ ____
| _ \ _ _/ ___| _ __ ___ ___/ ___|| _ \| _ \
| |_) | | | \___ \| '_ \ / _ \/ __\___ \| | | | |_) |
| __/| |_| |___) | |_) | __/ (__ ___) | |_| | _ <
|_| \__, |____/| .__/ \___|\___|____/|____/|_| \_\
|___/ |_|
PySpecSDR - Python SDR Spectrum Analyzer and Signal Processor
===========================================================
This is part of the PySpecSDR program.
It converts a GQRX CSV/Bookmark file to JSON/PySpecSDR format. Make
sure to save the file as sdr_bookmarks.json to load it to PySpecSDR,
as it is. You can also open the file to an editor and add entries from
it.
License: GPL-3.0-or-later
Copyright (c) 2024 [XQTR]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Author: XQTR
Email: [email protected] // [email protected]
GitHub: https://github.com/xqtr/PySpecSDR
Version: 1.0.0
Last Updated: 2024/11/30
'''
import csv
import json
import argparse
def gqrx_to_json(csv):
results = {}
with open(csv) as file:
for line in file:
line = line.strip()
if line.startswith('#'):
pass
elif line.startswith('Untagged'):
pass
elif not line:
pass
else:
#print(line.rstrip())
flds = line.split(';')
freq = float(flds[0])
name = flds[1].strip()
mode = flds[2].strip()
band = float(flds[3].strip())
if mode.startswith('Narrow'):
mode = "FM"
elif mode.startswith('AM'):
mode = "AM"
elif mode.startswith('WFM'):
mode = "WFM"
elif mode.startswith('CW'):
mode = "CW"
results[name]=[freq,mode,band]
return results
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Load GQRX bookmarks from a file and convert to JSON/PySpecSDR format.')
parser.add_argument('readfile', type=str, help='Path to the GQRX bookmarks file')
parser.add_argument('savefile', type=str, help='Filename to JSON file')
args = parser.parse_args()
with open(args.savefile, 'w') as f:
json.dump(gqrx_to_json(args.readfile), f, indent=2)