Design an Extensible Python File Parser
Design an Extensible Python File Parser
Design a pluggable file parsing framework in Python that can process multiple file formats such as CSV, JSON, and XML.
Requirements:
- Expose a common parser interface.
- Detect the correct parser from file metadata or extension.
- Return a normalized parsed representation regardless of input format.
- Make it easy to add support for a new file type without changing existing parser implementations.
- Handle malformed files and surface errors consistently.
Follow-up:
If parsing becomes CPU-bound and you need to process many large files in parallel, explain how you would parallelize the workload in Python across multiple CPU cores. Compare processes vs. threads, describe how you would distribute work, and explain how you would collect results and failures safely.
AI interview prep
Core dilemma
Designing a highly extensible and robust parsing framework while ensuring efficient and safe parallel processing for CPU-bound workloads in Python, balancing flexibility with performance and error resilience.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design an Extensible Python File Parser
Design an Extensible Python File Parser
Design a pluggable file parsing framework in Python that can process multiple file formats such as CSV, JSON, and XML.
Requirements:
- Expose a common parser interface.
- Detect the correct parser from file metadata or extension.
- Return a normalized parsed representation regardless of input format.
- Make it easy to add support for a new file type without changing existing parser implementations.
- Handle malformed files and surface errors consistently.
Follow-up:
If parsing becomes CPU-bound and you need to process many large files in parallel, explain how you would parallelize the workload in Python across multiple CPU cores. Compare processes vs. threads, describe how you would distribute work, and explain how you would collect results and failures safely.