Over the past couple of months we have been developing a library built specifically for parsing and writing data files.

The project is located here: http://code.google.com/p/datafeed/

An adapter based structure is used to make it easy to create different adapters for each component. Please see the components included in this library below.

Components

There are 3 main components to this library:

File

The File component is designed to read and write data feed files, at present there are the following adapters:

  • CSV

    • Dynamic (Scans the csv file for it's format automatically - loaded by default)

    • Standard (Delimiter ',' - Enclosure '"' - Escape '\' - Line ending '\n')

  • YAML (Awaiting development)

  • JSON (Awaiting development)

  • XML (Awaiting development)

Archive

The Archive component allows for adding multiple files to a zip file (or similar). There are the following adapters for the Archive component:

  • Zip

  • Tar (Awaiting development)

  • bzip (Awaiting development)

Transfer

The transfer component is designed to move files from one place to another. We have written a Stream adapter that allows us to send / receive a file to/from http, https, ftp (active mode), ftps and sftp if you have the PECL SSH2 extension loaded in PHP (Guide for Ubuntu here). In total there are two active Transfer adapters and some planned ones:

  • Stream

  • Ftp (Allows active or passive mode)

  • Local (Awaiting development)

Example Usage

We have created some examples of how you can quickly and easily use this code here: Example Usage. This is by no means extensive is an example only. The more you explore the library, the more you will be able to appreciate how powerful and flexible it is.

Contributors Required

This is an open source project release under the New BSD License.

We are looking for some developers to contribute to this project and help us finish the library by helping to develop the component adapters above that are marked as "(Awaiting development)".

Adapter Pattern

This is an adapter based system that allows for easy development. Modelled on the Zend Framework Zend_Db_Adapter system of Adapters, making use of the Abstract/Interface design pattern. This makes developing adapters easy to do individually and make them unit testable in isolation.

Unit Tests

For a robust library, everything is unit tested using PHPUnit. We have also made use of VFS Stream to Mock and test the File adapters. There are the odd things that cannot be directly unit tested like the FTP Transfer adapter as the FTP instance cannot be mocked.

Finally

If you are interested in contributing to this library, please get in contact with us using the contact details on the Google Code Project Page.

    Write a Reply...