static-gallery-generator/lib/GalleryTable.py

17 lines
580 B
Python
Raw Permalink Normal View History

2025-01-09 16:35:41 +00:00
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())