Spreadsheets
in package
Class Spreadsheet
Provides methods to extract information from CSV files as exported by pcbis.de function 'Titelexport'
Table of Contents
- array2csv() : bool
- Turns a PHP array into CSV file
- csv2array() : array<string|int, mixed>
- Extracts data from a single CSV file & processes it
- csvOpen() : array<string|int, mixed>
- Turns data from a single CSV file into a PHP array
- convertAge() : string
- Builds 'Altersangabe' attribute as exported with pcbis.de
- convertPageCount() : int
- Builds 'Seitenzahl' attribute as exported with pcbis.de
- convertPrice() : string
- Builds 'Preis' attribute as exported with pcbis.de
- convertTitle() : string
- Builds 'Titel' attribute as exported with pcbis.de
- sortArray() : array<string|int, mixed>
- Sorts a given array holding book information by certain sort order
Methods
array2csv()
Turns a PHP array into CSV file
public
static array2csv(array<string|int, mixed> $array, string $file[, string $delimiter = ',' ]) : bool
Parameters
- $array : array<string|int, mixed>
-
Source PHP array to read data from
- $file : string
-
Destination CSV file to write data to
- $delimiter : string = ','
-
Separator character
Return values
bool —csv2array()
Extracts data from a single CSV file & processes it
public
static csv2array(string $file[, string $delimiter = ';' ]) : array<string|int, mixed>
This only works with files exported from pcbis.de
Parameters
- $file : string
-
Source CSV file to read data from
- $delimiter : string = ';'
-
Delimiting character
Return values
array<string|int, mixed> —csvOpen()
Turns data from a single CSV file into a PHP array
public
static csvOpen(string $file[, array<string|int, mixed> $headers = null ][, string $delimiter = ';' ]) : array<string|int, mixed>
Parameters
- $file : string
-
Source CSV file to read data from
- $headers : array<string|int, mixed> = null
-
Header names for CSV data rows
- $delimiter : string = ';'
-
Delimiting character
Return values
array<string|int, mixed> —convertAge()
Builds 'Altersangabe' attribute as exported with pcbis.de
protected
static convertAge(string $string) : string
Parameters
- $string : string
-
'Altersangabe' string
Return values
string —convertPageCount()
Builds 'Seitenzahl' attribute as exported with pcbis.de
protected
static convertPageCount(string $string) : int
Parameters
- $string : string
-
'Seitenzahl' string
Return values
int —convertPrice()
Builds 'Preis' attribute as exported with pcbis.de
protected
static convertPrice(string $string) : string
Parameters
- $string : string
-
'Preis' string
Return values
string —convertTitle()
Builds 'Titel' attribute as exported with pcbis.de
protected
static convertTitle(string $string) : string
Parameters
- $string : string
-
'Title' string
Return values
string —sortArray()
Sorts a given array holding book information by certain sort order
protected
static sortArray(array<string|int, mixed> $array) : array<string|int, mixed>
TODO: https://www.php.net/manual/en/function.usort.php#25360
Parameters
- $array : array<string|int, mixed>
-
Input that should be sorted