load: ignore CryptPad's Participant column (real export is Time, Participant, then questions)
A real CryptPad Form export on 2026-10-27 had a Participant column full of "Guest", which the choice-column heuristic read as a checkbox question. Treat it as metadata like Time, and add a test with the real header shape. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8c43781fc
commit
68775856f4
2 files changed
+14
-1
No files matched your search
+1
-1
@@ -51,7 +51,7 @@ PRICES = {
|
||||
|
||||
KINDS = {"idea", "want", "need", "goal", "concern"}
|
||||
STANCES = {"for", "against", "neutral"}
|
||||
META_COL_RE = re.compile(r"^(id|#|time|timestamp|date|submitted|created|author|user)\b", re.I)
|
||||
META_COL_RE = re.compile(r"^(id|#|time|timestamp|date|submitted|created|author|user|participant)\b", re.I)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
@@ -76,6 +76,19 @@ class LoadTests(unittest.TestCase):
|
||||
self.assertEqual(loaded["questions"], ["Ideas"]) # Timestamp dropped as meta, Notes dropped as empty
|
||||
self.assertEqual([r["id"] for r in loaded["responses"]], ["r01", "r02"])
|
||||
|
||||
def test_cryptpad_export_meta_columns(self):
|
||||
# Real CryptPad Form export (2026-10-27): Time, Participant, then the questions.
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
p = Path(d) / "x.csv"
|
||||
p.write_text("Time,Participant,Ideas,Priorities (pick up to 3).\n"
|
||||
"2026-10-27T04:38:39.152Z,Guest,Build a shared prompt library members can contribute to.,\"privacy,green energy\"\n"
|
||||
"2026-10-27T04:39:01.002Z,Guest,Try office hours once a month so people meet each other.,privacy\n"
|
||||
"2026-10-27T04:39:22.418Z,Guest,Publish the energy numbers somewhere members can see them.,docs and onboarding\n")
|
||||
loaded = S.load_responses(p)
|
||||
self.assertEqual(loaded["questions"], ["Ideas"])
|
||||
self.assertEqual(loaded["choice_questions"], ["Priorities (pick up to 3)."])
|
||||
self.assertEqual(loaded["responses"][0]["choices"]["Priorities (pick up to 3)."], ["privacy", "green energy"])
|
||||
|
||||
def test_choice_heuristic_rejects_long_text(self):
|
||||
self.assertFalse(S.looks_like_choice_column(["a long free-text answer that goes on and on about many things"] * 5))
|
||||
self.assertTrue(S.looks_like_choice_column(["privacy, green", "green", "privacy; docs", "docs"]))
|
||||
|
||||
Reference in new issue
Block a user