Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Data Formats (JSON, YAML, TOML, XML, CSV) Module 1

Foundations: choosing formats and handling text interview questions

Interview questions on “Foundations: choosing formats and handling text”: warm-ups, then what each harder question tests and how a good answer starts.

7 questions: 3 warm-ups and 4 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    A format's syntax and its data model: how do they differ?

    The syntax is the set of rules for the text itself: which characters are allowed, how strings are quoted, what separates values. It decides whether a file can be parsed at all. The data model is the set of values you get after parsing: JSON gives objects, arrays, strings, numbers, true, false and null; CSV gives rows of text fields; XML gives elements, attributes and text. Two files can follow the syntax perfectly and still differ in what their data model can hold, which is why the same order read from JSON keeps 37900 as a number, while from CSV it comes back as the text "37900". Neither layer checks meaning: a schema states which values are allowed, such as a whole number of paise.

    From the lesson Choosing a data format: JSON, YAML, TOML, XML, CSV

  2. Fresher to mid

    Why is CSV called a format without types?

    Answered in the lesson Choosing a data format: JSON, YAML, TOML, XML, CSV

  3. Fresher to mid

    What is a byte-order mark, and why does JSON care?

    Answered in the lesson UTF-8, BOMs and line endings in data files

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    Your team wants to move a service's settings from config.json to config.yaml so that people can write comments. What would you check before agreeing, and what would you put in place so that the move cannot change the value of any setting?

    What it tests
    Knowing that YAML parsers type plain values by their version and schema, choosing the loader on purpose, quoting risky values, validating parsed values, and proving the move with a value-by-value comparison.
    First step
    Ask which parser will read the file, and which YAML version and schema it follows. JSON text is valid YAML 1.2, but people will not keep writing JSON: they write plain YAML, whose values are typed by the parser. Psych, a YAML 1.1 parser, read backup: 02:30:00 as the number 9000.
    Follow-ups

    From the lesson Choosing a data format: JSON, YAML, TOML, XML, CSV

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to senior

    Finance wants a daily export of orders they can open in a spreadsheet, and the billing service must import the same data. Which format or formats would you produce, and how would you keep amounts, ids and times exact for both?

    What it tests
    Producing one file per consumer from one source, keeping amounts in minor units, ids as text and times with their offset, and knowing the spreadsheet's 15-digit limit and how it reads columns.
    First step
    Name the two consumers and what each needs. People need rows and columns in a spreadsheet, so CSV; the service needs exact types, so JSON or JSON Lines. Write both from the same records in one job, with the same field names and the same rules for amounts, ids and times.
    Follow-ups

    From the lesson Choosing a data format: JSON, YAML, TOML, XML, CSV

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Fresher to mid

    A nightly import reads a CSV export with csv.DictReader. Since the export moved to a new tool, it fails with KeyError: 'name', although the first line of the file still reads name,city. What happened, and how do you fix the import and protect it from the next change of exporter?

    What it tests
    Recognising a UTF-8 byte-order mark in the first header, decoding with utf-8-sig, opening CSV with newline='', and checking the header and the bytes at the boundary.
    First step
    Print repr() of the header keys, or the first bytes of the file in hex. The first key is '\ufeffname' and the file starts EF BB BF: the new tool writes a UTF-8 byte-order mark, which plain utf-8 decoding keeps as part of the text.
    Follow-ups

    From the lesson UTF-8, BOMs and line endings in data files

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    A job reads a CSV file, changes one column and writes it back. A checksum comparison then reports every row with a two-line address as changed, although nobody edited the addresses. Where did the change happen, and how would you make the round trip exact?

    What it tests
    Knowing that RFC 4180 fields may hold line breaks, that universal newlines rewrite CRLF inside quoted fields, and that the csv module needs files opened with newline='' for reading and writing.
    First step
    Compare the bytes of one changed row before and after: the quoted address held CR LF and now holds LF. Then look at how the job opened the files. Without newline='', Python's universal newlines turned the CR LF inside the quotes into LF before the csv module read it.
    Follow-ups

    From the lesson UTF-8, BOMs and line endings in data files

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Data Formats (JSON, YAML, TOML, XML, CSV) interview questions · The Data Formats (JSON, YAML, TOML, XML, CSV) track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.