Skip to content

Masterlist CSV Import ​

Admins can populate the entire system — sections, subjects, teachers, students, and enrollments — from a single CSV file. Parsing is done by parseMasterlistCSV() (src/lib/csvParser.ts); the import is applied by importMasterlist() (src/app/actions/masterlist.ts).

Authoritative format

This page documents the format the parser actually expects. A ready-made sample lives at masterlist_template.csv in the repo root.

CSV format ​

One row = one student enrolled in one subject. A student who takes three subjects appears on three rows; the importer groups them automatically by student_id.

Required columns ​

ColumnDescriptionExample
section_nameClass/section nameBSIT 2nd Year
adviser_nameSection adviser's full nameMs. Alcantara
adviser_emailAdviser's login emailalcantara@school.com
subject_codeUnique subject codeNET201
subject_nameSubject nameData Communications
subject_teacher_nameSubject teacher's nameEngr. Torres
subject_teacher_emailSubject teacher's emailtorres@school.com
student_idUnique student ID (also initial password)2026-101
student_nameStudent's full nameClara Mendoza

Optional columns ​

ColumnDescriptionExample
subject_unitsUnits for the subject3
schedule_dayDay code; shorthand is expanded (see below)MWF
schedule_timeTime range09:00-10:30
student_emailStudent email (auto-handled if blank)clara@student.com
year_levelStudent's grade/year level2nd Year College

Schedule-day shorthand ​

schedule_day shorthand is normalised by the parser: MWF → Mon,Wed,Fri, TTh → Tue,Thu, Daily/MTWTF → Mon,Tue,Wed,Thu,Fri, and single days like Fri pass through. Comma-separated day lists are accepted as-is.

Example ​

csv
section_name,adviser_name,adviser_email,subject_code,subject_name,subject_teacher_name,subject_teacher_email,subject_units,schedule_day,schedule_time,student_id,student_name,student_email,year_level
BSIT 2nd Year,Ms. Alcantara,alcantara@school.com,NET201,Data Communications,Engr. Torres,torres@school.com,3,MWF,09:00-10:30,2026-101,Clara Mendoza,clara@student.com,2nd Year College
BSIT 2nd Year,Ms. Alcantara,alcantara@school.com,WEB202,Web Development,Prof. Garcia,garcia@school.com,3,TTh,13:00-14:30,2026-101,Clara Mendoza,clara@student.com,2nd Year College

Here Clara appears twice — once per subject — and ends up enrolled in both.

How the import behaves ​

importMasterlist() processes sections, then subjects, then students + enrollments. It is idempotent — you can safely import the same file multiple times.

EntityNewExisting (matched by)
SectionCreated with its adviserReused; adviser reassigned if changed (name)
Teacher/AdviserAccount created, default password teacher123Reused (email)
SubjectCreatedUpdated: name, teacher, units, schedule (code)
StudentAccount created; password = student ID; QR token generatedSection, name & year level updated (student_id)
EnrollmentCreated if missingSkipped if already enrolled

Account defaults created by import ​

RoleLoginInitial password
Teacher (new)Their emailteacher123
Student (new)Their email (or null if blank)Their student ID (e.g. 2026-101)

Import steps ​

  1. Go to Admin → Masterlist and click Import Masterlist.
  2. Select your .csv file. The system shows a preview with counts and any validation errors (missing required fields, missing columns, etc.).
  3. Click Confirm Import.
  4. A summary reports what was created, updated, or skipped, plus any per-row errors (for example, an email already in use).

Validation

If any required column is missing from the header, the whole file is rejected. Individual rows missing a required value are reported as errors and skipped, while valid rows still import.

Tips ​

  • Build the file in Excel/Google Sheets and export as .csv.
  • Keep student_id values unique across the whole system.
  • Wrap fields containing commas in quotes (e.g. "Dela Cruz, Juan"); the parser handles quoted fields.
  • One file can contain multiple sections and subjects.

Documentation for the Secure QR Attendance System.