runtime
225 / 500
question 225 CLI & Automation · medium

A manifest of data files by folder

A deploy step ships a project's data files and writes a manifest of what went where. Given the relative paths in the project, build the manifest for the CSV and JSON files.

Functionmanifest(paths)
pathsrelative paths with /, e.g. "data/2011/sales.csv"
Returnsa dictionary from folder ("." for the top level) to the sorted list of file names in it
Rulesonly suffixes .csv and .json, ignoring capitals; folders with no such files are left out; the input list is not changed
Examples
callmanifest(['data/2011/sales.csv', 'data/2011/returns.JSON', 'data/readme.md', 'data/2010/sales.csv', 'config.json'])returns{'data/2011': ['returns.JSON', 'sales.csv'], 'data/2010': ['sales.csv'], '.': ['config.json']}
callmanifest(['notes.md', 'src/app.py'])returns{}
callmanifest(['b/x.csv', 'b/a.csv'])returns{'b': ['a.csv', 'x.csv']}

Loading your progress…

A manifest of data files by folder — Python practice · Runtime