Created
May 20, 2022 17:56
-
-
Save jcurbelo/a8782ede7d2516ffb1d9416e59b740d0 to your computer and use it in GitHub Desktop.
Converts Adobe Bridge CSV into NiftyKit's metadata JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import json | |
import re | |
data = [] | |
result = [] | |
def extract_attrs(kwds_list): | |
kwds = kwds_list.split(';') | |
attrs = [] | |
for kwd in kwds: | |
# split kwd by '_', '-', ' ' | |
lst = re.split('[_ -]', kwd) | |
attrs.append({ | |
'trait_type': lst[0], | |
'value': ' '.join(lst[1:]), | |
}) | |
return attrs | |
def main(): | |
with open('original.csv', 'r') as csvfile: | |
reader = csv.DictReader(csvfile) | |
for row in reader: | |
data.append(row) | |
for d in data: | |
name = d['FileName'].split('.')[0] | |
result.append({ | |
'name': name, | |
'description': name, | |
'image': 'ipfs://your-cid/' + d['FileName'], | |
'attributes': extract_attrs(d['Keywords']), | |
'animation_url': '', | |
'background_color': '', | |
'youtube_url': '', | |
'external_url': '' | |
}) | |
with open('metadata.json', 'w') as f: | |
json.dump(result, f, indent=2) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment