swapped over to json for output

If two servers were found at the same time, they might try to write to the xlsx file  at the same time. this could corrupt the file. outputting to json, and just using another script to convert is much safer.
This commit is contained in:
Astatin3
2023-09-05 07:23:38 -06:00
parent 04322bacee
commit c7b5427fae
3 changed files with 60 additions and 25 deletions
+18
View File
@@ -0,0 +1,18 @@
import sys
import json
from openpyxl import Workbook
inputfile = sys.argv[1]
outputfile = sys.argv[2]
book = Workbook()
sheet = book.active
sheet.append(("ip", "latency", "pver", "ver", "cplayers", "mplayers", "motd", "isicon"))
with open(inputfile) as f:
data = json.load(f)
for entry in data:
sheet.append((entry["ip"], entry["latency"], entry["pver"], entry["ver"], entry["cplayers"], entry["mplayers"], entry["motd"], entry["isicon"]))
book.save(outputfile)