runtime
419 / 500
question 419 pandas Foundations · hard

Error report for a product feed

A supplier's product feed must be checked before import. For each data row, report the first problem found, checking in this order: the stock_code is empty ("missing stock code"); the list_price is empty or not a number ("price is not a number"); the price is 0 or less ("price must be positive"). Write feed_errors(path): return messages like "line 3: price is not a number", where the line number is the line in the file (the header is line 1).

Functionfeed_errors(path)
Filea CSV with stock_code,description,list_price
Returnsa list of messages in file order, one per bad row; [] when the feed is clean
Examples
callfeed_errors('feed.csv')returns['line 3: price is not a number', 'line 4: missing stock code', 'line 5: price must be positive']
callfeed_errors('clean.csv')returns[]

Loading your progress…

Error report for a product feed — Python practice · Runtime