https://github.com/rcmachado/fileparser
Provides file wrappers to parse text files.
https://github.com/rcmachado/fileparser
Last synced: 9 months ago
JSON representation
Provides file wrappers to parse text files.
- Host: GitHub
- URL: https://github.com/rcmachado/fileparser
- Owner: rcmachado
- License: mit
- Created: 2010-10-23T12:52:53.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2010-10-23T12:58:49.000Z (about 15 years ago)
- Last Synced: 2023-03-11T05:44:36.652Z (almost 3 years ago)
- Language: PHP
- Homepage:
- Size: 93.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
FP FileParser
=============
Provides differents file wrappers to parse text files.
Requirements
------------
* PHP 5.1+ (it depends on [SplFileObject](http://php.net/splfileobject) class)
License
-------
This project is licensed under MIT LICENSE. See file LICENSE or visit
[http://www.opensource.org/licenses/mit-license.html](http://www.opensource.org/licenses/mit-license.html)
for more information.
Installation
------------
For now, simply copy the FP folder to your project.
Parsers
-------
Currently, only FP_SubstringFile is available.
### SubstringFile
Parse each line of a file using substring positions. Empty lines are returned
as `null` values.
Example:
array(
// a field with the first 10 chars of line
array('size' => 10),
// we will skip the next 5 chars
array('size' => 5, 'skip' => true),
// then retrieve the next 15 chars, validating against a regexp
array('size' => 15, 'validate_using_re' => '/\w+\d+/'),
),
);
$file = new FP_SubstringFile('myfile.txt', $options);
foreach ($file as $fields) {
// $fields is the various fields that
// you especified in $options['format']
}
?>
Contributing
------------
* Fork this project and send-me a pull request OR
* Or just send a patch (you can create one using `git format-patch`) to
rcmachado@gmail.com
If possible, write an unit test for your feature or bugfix.
TO-DO list:
* Better documentation
* New wrappers (RegExp, ...)
* PEAR installation (package.xml file)