Parse Quoted CSV Rows From a Host Earnings Export
Last updated: November 29, 2026
Quick Overview
Write a parser for one line of a CSV earnings export where fields may be wrapped in double quotes, quoted fields may contain commas, and a doubled quote inside a quoted field represents a literal quote. Return the list of field values, then render them joined by a pipe character.
Airbnb
November 29, 20260
0
0 solved
Write a parser for one line of a CSV earnings export where fields may be wrapped in double quotes, quoted fields may contain commas, and a doubled quote inside a quoted field represents a literal quote. Return the list of field values, then render them joined by a pipe character.
Hosts download earnings and reservation reports as CSV, and listing titles routinely contain commas and quotes. A hand-written parser is a well-known Airbnb phone screen exercise because it tests careful state handling under time pressure, without any algorithmic trick to hide behind.
What the Interviewer Expects
- Define the grammar before coding
- Use a small state machine with an in_quotes flag
- Handle escaped double quotes correctly
- Preserve empty fields, including a trailing empty field
- Report malformed input such as an unterminated quote
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you support newlines inside quoted fields across multiple lines?
- How would you stream a 2 GB export without loading it into memory?
- Should text after a closing quote, like "abc"def, be an error or concatenated?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is a single line. Commas separate fields unless inside quotes. A quote at the start of a field opens a quoted section; inside it, "" is a literal quote and a single " closes it. Output prese...
High-Level Design
Walk the characters once with two states. Outside quotes: a comma ends the current field, a quote enters quoted mode, and anything else is appended. Inside quotes: a quote followed by another quote ap...