Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Parse Complex Data Format with Business Rules
00:00
5 left

Parse Complex Data Format with Business Rules

MediumPython

Problem

Tell me how you would parse a complex data format such as a CSV string and implement business logic based on conditional requirements.

Implement parse_csv_fees(csv_text) for CSV input with the header id,amount,currency,status,customer_type. Return one result per active row, preserving order. Standard CSV quoting and escaped quotes must be supported. For active rows, premium customers have a "0.00" fee; other customers pay 2% of the amount, plus "1.00" when the currency is EUR. Return dictionaries containing id and a two-decimal string fee.

Constraints

  • The input contains the required header exactly once.
  • 1 <= number of data rows <= 500
  • Each amount is a valid non-negative decimal with at most two fractional digits.
  • Each status is active or inactive, ignoring surrounding whitespace and case.
  • Each currency is USD or EUR.
  • Each customer_type is premium or standard.
  • CSV fields may contain commas, escaped quotes, or line breaks according to standard CSV rules.

Function Signature

def parse_csv_fees(csv_text):
Interviewer

Your question is Parse Complex Data Format with Business Rules. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.