A simple package for searching, renaming, deleting, reading, and writing .csv files.
- Class name: FileWorker
- Namespace: mdeschermeier\FileWorker
mixed FileWorker::getCSVData(string $filename, integer $max_line_size, string $delim)
Given a csv filename, parses the file and returns associative array of records with the header in the 'header' key of the returned array and a 2D array of records in the 'data' key.
- Visibility: public
- This method is static.
- $filename string
- $max_line_size integer
- $delim string
boolean FileWorker::writeCSVData(array $data, string $filename, array $header, string $mode)
Given a 2D array of records, a filename (or path), and optionally an array of header fields, this function will write data to a csv formatted file.
Also optionally takes a file write mode setting.
- Visibility: public
- This method is static.
- $data array
- $filename string
- $header array
- $mode string
boolean FileWorker::deleteFile(string $filename)
Simple wrapper for deleting files.
- Visibility: public
- This method is static.
- $filename string
mixed FileWorker::findFilesByExt(string $dir, string $filetypes, boolean $regex_passed)
File search utility by file extension. Supports regex matching via passing the pattern in through the second parameter, just be sure to flip $regex_passed to true if passing regex. Supplying just the first parameter returns all files found.
- Visibility: public
- This method is static.
- $dir string
- $filetypes string
- $regex_passed boolean
mixed FileWorker::findFilesByName(string $dir, string $term, boolean $regex_passed)
File search utility by filename. Supports regex matching via passing the pattern in through the second parameter, just be sure to flip $regex_passed to true if passing regex. Supplying just the first parameter returns all files found.
- Visibility: public
- This method is static.
- $dir string
- $term string
- $regex_passed boolean
mixed FileWorker::renameFile(string $original_name, string $new_name, string $parent_dir)
Simple wrapper for renaming files. Optional $parent_dir parameter for renaming files in non-local directories.
- Visibility: public
- This method is static.
- $original_name string
- $new_name string
- $parent_dir string
string FileWorker::buildRegex(string $term, boolean $regex_passed)
Compiles various search terms into regex patterns for use with public class methods. Returns a pattern that matches everything by default.
- Visibility: private
- This method is static.
- $term string
- $regex_passed boolean
README.md generated with evert/phpdoc-md.