Skip to content

Instantly share code, notes, and snippets.

@ryonagana
Created September 23, 2019 12:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryonagana/746381def381e3b17dc57cc9e59eca2a to your computer and use it in GitHub Desktop.
Save ryonagana/746381def381e3b17dc57cc9e59eca2a to your computer and use it in GitHub Desktop.
#!/usr/bin/python3.7
import os
import sys
import json
import csv
def usage():
print("=======================")
print("gen_tiles.py <file.csv>")
print("=======================")
sys.exit(0)
def LoadCSV(*args, **kwargs):
result = []
header = {
'version': 1,
}
result.append(header)
try:
with open(kwargs['csv_file'], "r") as fp:
reader = csv.reader(fp, delimiter=",")
for row in reader:
offset = row[2].split(";")
line = {row[0] : (row[1], offset, row[3])}
result.append(line)
return result
except:
print("File Not Found!")
sys.exit(-1)
if __name__ == "__main__":
if len(sys.argv) <= 1:
usage()
csv_data = LoadCSV(csv_file=sys.argv[1])
print( json.dumps(csv_data), file=sys.stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment