From f49c4903c2d81099ad63c75fe12f261815fb1211 Mon Sep 17 00:00:00 2001 From: endolith Date: Sun, 23 Oct 2022 13:33:29 -0400 Subject: [PATCH] Use sys.argv instead of hardcoded filename So you can it from the command line --- json2kml.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/json2kml.py b/json2kml.py index fb8bd27..1f30c0b 100644 --- a/json2kml.py +++ b/json2kml.py @@ -14,7 +14,12 @@ import codecs import html -inputFile = "Saved Places.json" +try: + inputFile = sys.argv[1] +except IndexError: + print("Usage: python json2kml.py filename.json") + exit(1) + outputFile = f'{inputFile[:-5]} [json2kml.py].kml' # JSON Encoding is UTF-8. Change stdout to UTF-8 to prevent encoding error