CsvReader
in package
Support class to build reserves data from CSV file(s).
Tags
Table of Contents
- $courses : array<string|int, mixed>
- Course data loaded from files
- $delimiter : string
- CSV delimiter
- $departments : array<string|int, mixed>
- Department data loaded from files
- $errors : string
- Error messages collected during loading.
- $files : array<string|int, mixed>
- Files to load
- $instructors : array<string|int, mixed>
- Instructor data loaded from files
- $loaded : bool
- Flag indicating whether or not we have processed data yet.
- $reserves : array<string|int, mixed>
- Reserves data loaded from files
- $template : array<string|int, mixed>
- Field template (value => index)
- __construct() : mixed
- Constructor
- getCourses() : array<string|int, mixed>
- Get course data
- getDepartments() : array<string|int, mixed>
- Get department data
- getErrors() : string
- Get collected error messages
- getInstructors() : array<string|int, mixed>
- Get instructor data
- getReserves() : array<string|int, mixed>
- Get reserves data
- getValueFromLine() : string
- Load the appropriate data field from the line using our template.
- load() : void
- Load data if it is not already loaded.
- loadFile() : void
- Load data from a single file.
Properties
$courses
Course data loaded from files
protected
array<string|int, mixed>
$courses
= []
$delimiter
CSV delimiter
protected
string
$delimiter
$departments
Department data loaded from files
protected
array<string|int, mixed>
$departments
= []
$errors
Error messages collected during loading.
protected
string
$errors
= ''
$files
Files to load
protected
array<string|int, mixed>
$files
$instructors
Instructor data loaded from files
protected
array<string|int, mixed>
$instructors
= []
$loaded
Flag indicating whether or not we have processed data yet.
protected
bool
$loaded
= false
$reserves
Reserves data loaded from files
protected
array<string|int, mixed>
$reserves
= []
$template
Field template (value => index)
protected
array<string|int, mixed>
$template
Methods
__construct()
Constructor
public
__construct(array<string|int, mixed>|string $files[, string $delimiter = ',' ][, string $template = null ]) : mixed
Parameters
- $files : array<string|int, mixed>|string
-
Array of files to load (or single filename).
- $delimiter : string = ','
-
Delimiter used by file(s).
- $template : string = null
-
Template showing field positions within file(s). Comma-separated list containing BIB_ID, INSTRUCTOR, COURSE, DEPARTMENT and/or SKIP. Default = BIB_ID,COURSE,INSTRUCTOR,DEPARTMENT
Tags
Return values
mixed —getCourses()
Get course data
public
getCourses() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getDepartments()
Get department data
public
getDepartments() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getErrors()
Get collected error messages
public
getErrors() : string
Return values
string —getInstructors()
Get instructor data
public
getInstructors() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getReserves()
Get reserves data
public
getReserves() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getValueFromLine()
Load the appropriate data field from the line using our template.
protected
getValueFromLine(array<string|int, mixed> $line, string $key) : string
Parameters
- $line : array<string|int, mixed>
-
CSV row
- $key : string
-
Value to load
Return values
string —load()
Load data if it is not already loaded.
protected
load() : void
Tags
Return values
void —loadFile()
Load data from a single file.
protected
loadFile(string $fn) : void
Parameters
- $fn : string
-
Filename