Band Contacts to Google Contacts v2

This commit is contained in:
2026-06-23 09:47:19 -07:00
parent 919d717675
commit 6fe273d9d2
+27 -4
View File
@@ -3,6 +3,29 @@ import argparse
import datetime import datetime
import re import re
def clean_instrument_name(instrument_raw):
"""Cleans the instrument name based on Percussion, Winds, and Default rules."""
# Strip numerical prefix (e.g., "12 - Percussion (electronics)" -> "Percussion (electronics)")
if '-' in instrument_raw:
instrument = instrument_raw.split('-', 1)[-1].strip()
else:
instrument = instrument_raw.strip()
lower_inst = instrument.lower()
# 1. The Percussion Rule
if 'percussion' in lower_inst and '(' in instrument and ')' in instrument:
match = re.search(r'\((.*?)\)', instrument)
if match:
return match.group(1).strip().title()
# 2. The Winds/General Rule
elif '(' in instrument and ')' in instrument:
return re.sub(r'\(.*?\)', '', instrument).strip()
# 3. Default Rule
return instrument
def get_category(instrument): def get_category(instrument):
"""Categorize the instrument into Woodwinds, Brass, Percussion, or Colorguard.""" """Categorize the instrument into Woodwinds, Brass, Percussion, or Colorguard."""
inst_lower = instrument.lower() inst_lower = instrument.lower()
@@ -78,9 +101,9 @@ def main():
last_name = name_parts[0].strip() if len(name_parts) > 0 else "" last_name = name_parts[0].strip() if len(name_parts) > 0 else ""
first_name = name_parts[1].strip() if len(name_parts) > 1 else "" first_name = name_parts[1].strip() if len(name_parts) > 1 else ""
# Parse Instrument (e.g., "04 - Tenor Sax" -> "Tenor Sax") # Parse and Clean Instrument
section_raw = row.get('SECTION', '').strip() section_raw = row.get('SECTION', '').strip()
instrument = section_raw.split('-', 1)[-1].strip() if '-' in section_raw else section_raw instrument = clean_instrument_name(section_raw)
if not instrument: if not instrument:
instrument = "Unknown" instrument = "Unknown"
@@ -94,9 +117,9 @@ def main():
else: else:
notes = grade_raw notes = grade_raw
# Determine Label # Determine Label (Appended with Marching Band)
category = get_category(instrument) category = get_category(instrument)
label = f"{target_year} {category} ::: Marching Band ::: * myContacts" label = f"{target_year} {category} ::: Marching Band {target_year} ::: * myContacts"
# Build the output row # Build the output row
out_row = {key: "" for key in google_headers} out_row = {key: "" for key in google_headers}