-
Notifications
You must be signed in to change notification settings - Fork 2
/
Compiler.py
38 lines (31 loc) · 1.52 KB
/
Compiler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Imports CSV read and JSON write functions
import csv
import json
#Adjust CSV filename as needed
with open('Roster.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
#Loops through CSV rows, each containing a single token's characteristics
for row in csv_reader:
#Optional if statement to process only certain tokens if desired
if line_count >= 0:
line_count += 1
#IPFS CAR pin for token collection images (replace for your collection's images if building tokens)
archive = "ipfs://bafybeiatmiig6ylhha5p7o7bxvqutfitv6k2n5ghche4r22tgkmoz6gu5u/"
#Create a variable for each token trait (by row)
filename = row[0]
name = row[1]
park = row[2]
type = row[3]
feature = row[4]
#Convert the variables into JSON format
NFTjson = {"name":name,"description":"Pics from parks around the world.","image":archive+filename+".png","properties":{"Park":park,"Type":type,"Feature":feature}}
#Translate into a string, create a new JSON with a name matching the token ID, write the JSON, and save the JSON
jsonString = json.dumps(NFTjson)
jsonFile = open(filename+".json", "w")
jsonFile.write(jsonString)
jsonFile.close()
else:
line_count += 1
#Optional tracker to confirm completion
print(f'Processed {line_count} lines.')