Skip to content

Instantly share code, notes, and snippets.

@evanp
Created May 16, 2024 20:49
Show Gist options
  • Save evanp/bbffcbe3b8fc2e3a2147f0171e479691 to your computer and use it in GitHub Desktop.
Save evanp/bbffcbe3b8fc2e3a2147f0171e479691 to your computer and use it in GitHub Desktop.
from csv import DictReader as CSVReader
def csv2godot(csv_file, godot_file):
data = []
with open(csv_file, 'r') as f:
reader = CSVReader(f)
for row in reader:
data.append(row)
with open(godot_file, 'w') as f:
f.write('[')
for row in data:
f.write('{')
for key, value in row.items():
f.write(f"'{key}': '{value}', ")
f.write('},\n')
f.write(']')
if __name__ == '__main__':
import sys
csv2godot(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment