DVPPython Studio
Module 3: Process the whole bin / Build 4 of 4

Export the asset manifest

Write real JSON and CSV files to a new folder and prove their ordered, typed records agree.

Runs on your computer · 60–85 minutes · no paid services

Download practice filesFiles, commands & notes

Without JavaScript, use the step links and keep your files on your computer.

One useful idea

Use one internal record list for both formats. The reviewed validate_manifest helper checks exact path/extension/bytes fields, canonical unique relative paths, a matching supported lowercase suffix and non-boolean integer bytes from 0 through 10^15. Validate every row before creating output. This narrow path policy refuses formula-like prefixes; inspect unfamiliar CSV as text, not by double-clicking it in spreadsheet software.

Destination must be a new directory with an existing parent. mkdir without exist_ok=True refuses an existing location; exclusive x opens refuse existing files. Use UTF-8 for JSON and CSV, newline="" for csv.DictWriter, and fields path/extension/bytes in that order. A comma in a filename needs CSV quoting, not manual joining. Empty records still produce a header and an empty JSON array.

CSV reads all fields as strings. Convert bytes back to integers before comparing its ordered records with JSON and source. Return the two absolute Paths and row count only after both writes finish; demo.py actually reads them back and checks parity before claiming verification. This two-file write is not transactional: an I/O failure can leave a partial new folder. Expose the error, inspect that folder and choose another new name; never silently overwrite, delete or report success.

Refresh first: The inventory record schema, JSON serialization, CSV fields and quoting, CLI failures and success boundaries.

Trace a finished example

python -X utf8 demo.py --build 4 --output sample-export
# Writes sample-export/manifest.json and sample-export/manifest.csv
# Round-trip: JSON = CSV = source (4 rows)
# A second run refuses sample-export; choose another new folder.

The reference inventory supplies one validated record list. Both new files are written, then parsed back. The comma-containing path remains one CSV cell, Café remains Unicode text and bytes becomes an integer again. All four ordered records must agree before the demo prints the verified result.

The finished implementation is in collection_tools.py and demo.py. Reading it is guided practice, not independent evidence.

Predict the type

Why does CSV read bytes "32" rather than integer 32?

Compare your answer · self-reviewed

CSV stores text fields. Convert the declared byte field back to int before comparing typed records; do not compare raw string displays.

Find the destructive default

Why not open an existing manifest.json with mode w?

Compare your answer · self-reviewed

That overwrites prior work. Use a new output directory and exclusive file opens; an existing destination is a useful refusal, not permission to replace it.

Explain partial failure

Does a failed second write prove the first file never appeared?

Compare your answer · self-reviewed

No. The pair is not transactional. A new partial folder can remain, but no successful receipt or verified claim should be produced.

Change it, then build your own

One controlled change

Run the reference export once, inspect both files, then run the same command again. Check its error status immediately with $LASTEXITCODE in PowerShell or echo $? on macOS/Linux. Change only the output folder name for a new run.

Your independent task

Implement export_manifest(records, destination) in practice.py using the provided validate_manifest helper. Validate before writes, refuse existing/link destinations, create only the new directory and exclusively write manifest.json and manifest.csv as specified. Preserve input order and schema; return exactly json/csv absolute Paths and rows after both files succeed. Let I/O errors propagate; no overwrite or implicit cleanup.

What success looks like

Five export test methods pass, including real Unicode/comma round-trips, native byte types, empty output, unchanged inputs, validation before creation, existing-output preservation and exposed I/O errors. Then all 17 module methods pass. The demo’s --target practice option tests your writer with independently supplied reference inventory, not your unfinished Build 1 function.

Hint 1 · a question

Identify the shared record schema and which steps can change the filesystem. Validation must precede them.

Hint 2 · a concept cue

Use a new directory, exclusive opens, UTF-8 and newline="". JSON key order/spacing can vary; parsed records and list order must agree.

Hint 3 · a localized example

csv.DictWriter(file, fieldnames=["path", "extension", "bytes"]) handles quoting. Write the header even for zero rows, then all validated rows; return a receipt only after both contexts close.

Need the complete worked solution?

Open collection_tools.py and demo.py from the kit. Trace it, close it, then try fresh inputs in your own files. Treat the attempt as guided; seeing the solution does not award a practical pass.

Course help is guidance, not independent evidence. With JavaScript, opening help records guidance locally; otherwise note it in your README. Reset does not erase that history.

Repair a failed check

If rows split at a comma, replace manual string joining with csv.writer/DictWriter. If equality fails only on bytes, restore its declared integer type when reading CSV. If an invalid second row leaves an output folder, finish validation before mkdir. Never change a refused destination into exist_ok=True.

NotImplementedError means a practice stub is still unfinished. Read the failing test name and the last error line. Change one behavior, rerun that build, then rerun all implemented builds.

Show it works on new inputs

Build a different temporary inventory with at least five named entries, including ignored and nested files. Export the included records to a new folder, run a real JSON/CSV parity comparison, and show an existing-folder refusal without altering it. Keep files, commands, results and limitations in your README.

Self-review: name the input, result, refused case and reason. Your local test output and explanation are separate from a quiz score; this page does not certify a pass.

Keep the idea

You have a real collection-processing increment, not the complete Asset Intelligence portfolio. Module 4 integrates validation, resilient inspection, audit logs and a defensible CLI.

Module 3 checkpoint

Five questions, followed by the separate practical task above. JavaScript loads the scored questions; the build, files and hints remain available without it.