static-gallery-generator/lib/GalleryTable.py

17 lines
580 B
Python

import csv
GALLERY_TABLE_HEADERS = ["File", "Thumbnail", "Title", "Description", "Tags (with commas in-between)"]
def parse_table(file_path):
results = {}
with open(file_path, "r", encoding="utf-8") as file:
reader = csv.DictReader(file)
for row in reader:
results[row["File"]] = row
return results
def write_table(file_path, results):
with open(file_path, "w", encoding="utf-8") as file:
writer = csv.DictWriter(file, GALLERY_TABLE_HEADERS, quoting=csv.QUOTE_ALL, extrasaction="ignore")
writer.writeheader()
writer.writerows(results.values())