Skip to main content

Understanding CSV Data

CSV means comma-separated values. Each line is a record and each position represents a field.

match_id,team_name,wins,losses
M001,Fictional Falcons,4,1
M002,Sample Sharks,3,2

The first row is a header. Quoted fields may contain commas, so do not process CSV with explode(","); use fgetcsv().

Inspect before importing

Identify headers, data types, required fields, allowed ranges, unique identifiers, missing values and any fields that relate to other tables.

Treat every upload as untrusted input. A file being supplied with a task does not remove the need for validation.

Check

  • Headers have meaning and match expected fields.
  • Every row has the expected number of columns.
  • Numeric and identifier rules are documented.
  • All classroom records are fictional.