Skip to content

Instantly share code, notes, and snippets.

@dugjason
Created June 18, 2012 12:00
Show Gist options
  • Save dugjason/2948042 to your computer and use it in GitHub Desktop.
Save dugjason/2948042 to your computer and use it in GitHub Desktop.
Simple PHP script to read a DataSift JSON export file line-by-line
<?php
$filename = dirname(__FILE__) . '/part-r-00000.json';
$filehandle = fopen($filename, 'r');
if ($filehandle) {
while (($interaction = fgets($filehandle)) !== false) {
// Set $interaction as the full JSON interaction, ready for processing.
$interaction = json_decode($interaction, true);
// Code ...
}
fclose($filehandle);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment