mirror of
https://github.com/Astatin3/pymcstatus.git
synced 2026-06-08 16:18:05 -06:00
c7b5427fae
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.
18 lines
482 B
Python
18 lines
482 B
Python
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) |