learning-it by example

#325 Forward deployed engineer interviews 6.5 min

Parse a Messy CSV Live: Interview Round in Python

A messy file, five checks, five attempts. The first passes 1 of 5. The last passes all 5.

1. In the live-round exercise, what did the video do before writing any parsing code?
2. As the five attempts ran, how many of the five checks passed at each step?
3. Why does the video turn the amount N/A into nothing rather than zero?
4. How does the video read the date 03/04/2026, and what does it say to do in a real round?
5. Why does splitting every line on commas fail on the first data row of the messy file?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. See what splitting on commas does

    Copy the code folder first. In the folder run python -c "import steps; print(steps.step1()[0]); print(steps.step2()[0])". Compare the two printed rows field by field. Explain in one sentence why the first row has the wrong values in the 'joined' and 'amount' fields.

    A hint

    The first data row has commas inside quoted fields. In step 1 the name field holds only half of the name, and the later fields are shifted along.

  2. Read dates month first

    In steps.py, in the iso function, change "%d/%m/%Y" to "%m/%d/%Y". Predict how many checks pass at step 5. Then run python run.py and python -c "import steps; print([r['joined'] for r in steps.step5()])". Compare the dates with what you get from the original file.

    A hint

    The checks only test that dates are in ISO form. The original gives 2026-04-03 for Ben Jones and this change gives 2026-03-04, yet 5 of 5 pass.

  3. Turn a missing amount into zero

    Put the date format back. In steps.py, in the number function, change 'return None' to 'return 0.0'. Predict whether all five checks will still pass. Run python run.py and python -c "import steps; print([r['amount'] for r in steps.step5()])". Then explain why the video says this is a mistake.

    A hint

    Look at the last value in the printed list. The video says a missing amount and zero are different facts.

  4. Write a month in full

    Put number back. In messy.py change '4 Mar 2026' to '4 March 2026'. Predict which checks will fail at step 5 and what the run will do at the end. Run python run.py. Then look at the format codes in the iso function and say which one cannot read the new text.

    A hint

    One format code reads the short month name. I saw 4 of 5 checks pass at step 5, 'dates are ISO' failing, and the run stopping with an error.

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

A tiny made-up file with five planted problems; 03/04/2026 is read day first by assumption; no large files, encodings or short rows.

Up next in Forward deployed engineer interviews

More in Forward deployed engineer interviews

All Forward deployed engineer interviews videos

Related videos