Structures textual data as fields separated by a delimiter, such as a comma or tab. A header line commonly names the columns, while later lines represent records. section 19.0 section 19.5
A practical parsing workflow:
- Read the header and split it on the delimiter. section 19.1.2
- Split each data line, pair fields with headers, and create dictionaries. section 19.1.2
- Use the csv module for delimited formats, then coerce numeric text with int() or float(). section 19.5
Workout data
Given exercise,reps followed by Burpees,20-50, parsing produces {'exercise': 'Burpees', 'reps': '20-50'}. The resulting records can drive a random workout and formatted table output. section 19.0 section 19.1.2
$ head -3 inputs/exercises.csv exercise,reps Burpees,20-50 Situps,40-100
Shows the compact CSV input that becomes a collection of named records. section 19.0
