this is a work in process!
say you've got a csv file set up like so:
TITLE,AUTHOR,DATE,PUBLISHER,FORMAT,PAGES,"DUE DATE"
"Title of book","Famous Author","12-01-2004","Big Publisher","Paperback",336,-
and so on for thousands of rows.
set up a script like so:
$csv = new CSV\Query("path/to/file.csv");
$csv->to("path/to/export")
->select("*")
->where(function($row){
return $row['DATE'] < date("m-d-Y", strtotime("last year"));
})
->limit(1000)
->execute()
;
and before you can say "snack time anytime" you'll have a new csv file waiting for you!
executes the query
filters each row via provided callback, which is provided an associative array representing the row (keys are headers). (also available as CSV\Query::where()
)
- keys must match header case.
limit the number of items returned
choose which columns to return. *
will return all columns.
applies transformation to each row via provided callback, which is provided an associative array representing the row (keys are headers).
- keys must match header case.
- callback argument must be a pass-by-value argument
sets the export path, defaults to php://output
apply a filter function to each row. provides the callable with an associative array whose keys are the CSV's headings.
returns item count. use $csv->getCount(true)
to include header row
returns filter callable
returns array of output headers
returns the item limit
returns the input csv file's line count. note: if CSV\Query::limit()
is used, this number will be the total number of rows read until the limit was reached
returns the path to the output file
returns array of input headers