项目作者: manindertaggar

项目描述 :
Reads OpenLibrary books dump as Packets from the compressed .gz format
高级语言: PHP
项目地址: git://github.com/manindertaggar/OLDumpReader.git
创建时间: 2017-04-07T15:52:11Z
项目社区:https://github.com/manindertaggar/OLDumpReader

开源协议:

下载


OLDumpReader

PHP Library that reads OpenLibrary books dump as Packets from the compressed .gz format

OpenLibrary Dumps are available at
Download Dump link

Requirements:

  • Composer
  • PHP

How to use OLDumpReader:

add folowining code inside your composer.json

  1. "repositories": [
  2. {
  3. "type": "vcs",
  4. "url": "https://github.com/manindersingh030/OLDumpReader.git"
  5. }
  6. ...
  7. ],
  8. "require": {
  9. "taggar/ol-dump-reader": "dev-master",
  10. ...
  11. }
  12. `

and run $composer update

inside php file

  1. <?php
  2. require __DIR__.'/../vendor/autoload.php';
  3. use OLDumpReader\OlReader;
  4. $dumpLocation ='<dump_full_path>';
  5. $reader = new OLReader($dumpLocation);
  6. $reader->seekToLastLocation();
  7. var_dump($reader->getNextPacket());

Documentation

Available Methods

getNextPacket()
  1. returns next packet as array
  2. note: includes starting_location and ending_location key which represents locations inside compressed file of starting and ending of packet respectively
getNextRawPacket()
  1. returns next packet as raw string
output format as Raw Packet

each of following is seprated by a tab ‘\t’

  1. <packet_starting_inside_compressed_file> <packet_ending_inside_compressed_file> <type> <key> <revision> <last_modified> <json>
seekToLastLocation()
  1. moves currunt pointer to last known packet location.
  2. note: this doesnot goes at the end of the file but seeks to location of last packet that was parsed.
seekToPosition($seekLocation);
  1. moves pointer to $seekLocation