Solved

What is parsing mean?

Posted on 2014-09-23
14
184 Views
Last Modified: 2014-09-24
I want to sound intelligent and I want to do this right the first time. I'm being asked to parse the following file:

{"id":"tag:search.twitter.com,2005:389903668427763712","objectType":"activity","actor":{"objectType":"person","id":"id:twitter.com:91239297","link":"http://www.twitter.com/OGkush103","displayName":"WalkingLick74","postedTime":"2009-11-20T01:21:39.000Z","image":"https://si0.twimg.com/profile_images/378800000593715086/755411d8bdc495472c2d7ed50e319582_normal.jpeg","summary":"Self-Made, Self Paid..... I always had the mind to get it like a man, head first bout my younging Ean! #YOLO","links":[{"href":null,"rel":"me"}],"friendsCount":468,"followersCount":677,"listedCount":0,"statusesCount":25504,"twitterTimeZone":"Alaska","verified":false,"utcOffset":"-28800","preferredUsername":"OGkush103","languages":["en"],"location":{"objectType":"place","displayName":"Boston George Crib"},"favoritesCount":26},"verb":"post","postedTime":"2013-10-15T00:00:53.000Z","generator":{"displayName":"Twitter for iPhone","link":"http://twitter.com/download/iphone"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/OGkush103/statuses/389903668427763712","body":"You a killer you on twitter, You'n do NO talking","object":{"objectType":"note","id":"object:search.twitter.com,2005:389903668427763712","summary":"You a killer you on twitter, You'n do NO talking","link":"http://twitter.com/OGkush103/statuses/389903668427763712","postedTime":"2013-10-15T00:00:53.000Z"},"favoritesCount":0,"location":{"objectType":"place","displayName":"Mississippi, US","name":"Mississippi","country_code":"United States","twitter_country_code":"US","link":"https://api.twitter.com/1.1/geo/id/43d2418301bf1a49.json","geo":{"type":"Polygon","coordinates":[[[-91.65500899999999,30.146096],[-91.65500899999999,34.996099],[-88.097888,34.996099],[-88.097888,30.146096]]]}},"geo":{"type":"Point","coordinates":[31.99686058,-88.72688823]},"twitter_entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[]},"twitter_filter_level":"medium","twitter_lang":"en","retweetCount":0,"gnip":{"matching_rules":[{"tag":null}],"language":{"value":"en"}}}

"id:twitter.com:91239297"," is one of the fields that I've got to capture. They're wanting a csv file at the end, so what does that mean? Does that mean they want something like this:

column name: "id:twitter.com:91239297","
cell info: ","link":"http://www.twitter.com/OGkush103","displayName":"WalkingLick74","postedTime":"2009-11-20T01:21:39.000Z","image":"https://si0.twimg.com/profile_images/378800000593715086/755411d8bdc495472c2d7ed50e319582_normal.jpeg","summary":"Self-Made, Self Paid..... I always had the mind to get it like a man, head first bout my younging Ean! #YOLO","links":[{"href":null,"rel":"me"}],"friendsCount":468,"followersCount":677,"listedCount":0,"statusesCount":25504,"twitterTimeZone":"Alaska","verified":false,"utcOffset":"-28800","preferredUsername":"OGkush103","languages":["en"],"location":{"objectType":"place","displayName":"Boston George Crib"},"favoritesCount":26},"verb":"post",

column name: "postedTime":"2013-10-15T00:00:53.000Z","generator":{"displayName":"Twitter for iPhone","
cell info: ","link":"http://twitter.com/download/iphone"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/OGkush103/statuses/389903668427763712","body":"You a killer you on twitter, You'n do NO talking","object":{"objectType":"note","id":"object:search.twitter.com,2005:389903668427763712","summary":"You a killer you on twitter, You'n do NO talking","link":"http://twitter.com/OGkush103/statuses/389903668427763712","postedTime":"2013-10-15T00:00:53.000Z"},"favoritesCount":0,"location":{"objectType":"place","displayName":"Mississippi, US","name":"Mississippi","country_code":"United States","twitter_country_code":"US","link":"https://api.twitter.com/1.1/geo/id/43d2418301bf1a49.json","geo":{"type":"Polygon","coordinates":[[[-91.65500899999999,30.146096],[-91.65500899999999,34.996099],[-88.097888,34.996099],[-88.097888,30.146096]]]}},

Open in new window


I'm shooting in the dark, here. Any guidance would be very cool!

Thanks!
0
Comment
Question by:brucegust
  • 4
  • 4
  • 2
  • +3
14 Comments
 
LVL 19

Expert Comment

by:Iammontoya
ID: 40339482
Parsing, in this context, is simply "reading" through the whole thing, and making it easy to identify one piece from another.

if I parse inigo.montoya@myplace.com, I could get:
           Inigo
           Montoya
           myplace.com
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40339485
FIRST, test it here : http://www.jslint.com/
if valid, play with it here : http://jsonviewer.stack.hu/
0
 
LVL 19

Expert Comment

by:Iammontoya
ID: 40339488
In your case, you will probably load the whole thing, maybe into an array, and you will parse it into intelligent pieces.
0
 
LVL 32

Assisted Solution

by:Big Monty
Big Monty earned 125 total points
ID: 40339506
parsing is when you extract specific pieces of data from a data source. In this case, the data source is a string, in JSON format. I recommend having a look at this brief article that'll explain how to parse out the data:

http://www.w3schools.com/json/json_eval.asp

here's an example you can use for reference:

<!DOCTYPE html>
<html>
<body>

<h2>Create Object from JSON String</h2>

<p id="demo"></p>

<script>
var text = '{"employees":[' +
'{"firstName":"John","lastName":"Doe" },' +
'{"firstName":"Anna","lastName":"Smith" },' +
'{"firstName":"Peter","lastName":"Jones" }]}';

obj = JSON.parse(text);
document.getElementById("demo").innerHTML =
obj.employees[1].firstName + " " + obj.employees[1].lastName;
</script>

</body>
</html>

Open in new window

0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 375 total points
ID: 40339636
This looks like a JSON string.  JSON stands for JavaScript Object Notation.  It's useful with many languages in addition to JavaScript.
http://json.org/

JSON has largely supplanted XML for data transport.  It can do more than XML and it's got a better propellant-to-payload ratio, so it's more efficient.  All JSON is UTF-8, so western European accented characters may require conversion from ISO-8859-1 or Windows-1252 encoding.  Information about character encoding is available here.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html

PHP has the JSON_decode() function that will turn the JSON string back into a PHP object.  Once that is done, you can access the properties of the object with standard PHP OOP notation.  However in this case, the test data is invalid JSON.  Perhaps it was truncated when you posted it?

<?php // demo/temp_brucegust.php
error_reporting(E_ALL);
echo '<pre>';

// SEE TEST DATA AT http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28523915.html
$jso = <<<EOD
{"id":"tag:search.twitter.com,2005:389903668427763712","objectType":"activity","actor":{"objectType":"person","id":"id:twitter.com:91239297","link":"http://www.twitter.com/OGkush103","displayName":"WalkingLick74","postedTime":"2009-11-20T01:21:39.000Z","image":"https://si0.twimg.com/profile_images/378800000593715086/755411d8bdc495472c2d7ed50e319582_normal.jpeg","summary":"Self-Made, Self Paid..... I always had the mind to get it like a man, head first bout my younging Ean! #YOLO","links":[{"href":null,"rel":"me"}],"friendsCount":468,"followersCount":677,"listedCount":0,"statusesCount":25504,"twitterTimeZone":"Alaska","verified":false,"utcOffset":"-28800","preferredUsername":"OGkush103","languages":["en"],"location":{"objectType":"place","displayName":"Boston George Crib"},"favoritesCount":26},"verb":"post","postedTime":"2013-10-15T00:00:53.000Z","generator":{"displayName":"Twitter for iPhone","link":"http://twitter.com/download/iphone"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/OGkush103/statuses/389903668427763712","body":"You a killer you on twitter, You'n do NO talking","object":{"objectType":"note","id":"object:search.twitter.com,2005:389903668427763712","summary":"You a killer you on twitter, You'n do NO talking","link":"http://twitter.com/OGkush103/statuses/389903668427763712","postedTime":"2013-10-15T00:00:53.000Z"},"favoritesCount":0,"location":{"objectType":"place","displayName":"Mississippi, US","name":"Mississippi","country_code":"United States","twitter_country_code":"US","link":"https://api.twitter.com/1.1/geo/id/43d2418301bf1a49.json","geo":{"type":"Polygon","coordinates":[[[-91.65500899999999,30.146096],[-91.65500899999999,34.996099],[-88.097888,34.996099],[-88.097888,30.146096]]]}},"geo":{"type":"Point","coordinates":[31.99686058,-88.72688823]},"twitter_entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[]},"twitter_filter_level":"medium","twitter_lang":"en","retweetCount":0,"gnip":{"matching_rules":[{"tag":null}],"language":{"value":"en"}}}

"id:twitter.com:91239297"," is one of the fields that I've got to capture. They're wanting a csv file at the end, so what does that mean? Does that mean they want something like this:

column name: "id:twitter.com:91239297","
cell info: ","link":"http://www.twitter.com/OGkush103","displayName":"WalkingLick74","postedTime":"2009-11-20T01:21:39.000Z","image":"https://si0.twimg.com/profile_images/378800000593715086/755411d8bdc495472c2d7ed50e319582_normal.jpeg","summary":"Self-Made, Self Paid..... I always had the mind to get it like a man, head first bout my younging Ean! #YOLO","links":[{"href":null,"rel":"me"}],"friendsCount":468,"followersCount":677,"listedCount":0,"statusesCount":25504,"twitterTimeZone":"Alaska","verified":false,"utcOffset":"-28800","preferredUsername":"OGkush103","languages":["en"],"location":{"objectType":"place","displayName":"Boston George Crib"},"favoritesCount":26},"verb":"post",

column name: "postedTime":"2013-10-15T00:00:53.000Z","generator":{"displayName":"Twitter for iPhone","
cell info: ","link":"http://twitter.com/download/iphone"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/OGkush103/statuses/389903668427763712","body":"You a killer you on twitter, You'n do NO talking","object":{"objectType":"note","id":"object:search.twitter.com,2005:389903668427763712","summary":"You a killer you on twitter, You'n do NO talking","link":"http://twitter.com/OGkush103/statuses/389903668427763712","postedTime":"2013-10-15T00:00:53.000Z"},"favoritesCount":0,"location":{"objectType":"place","displayName":"Mississippi, US","name":"Mississippi","country_code":"United States","twitter_country_code":"US","link":"https://api.twitter.com/1.1/geo/id/43d2418301bf1a49.json","geo":{"type":"Polygon","coordinates":[[[-91.65500899999999,30.146096],[-91.65500899999999,34.996099],[-88.097888,34.996099],[-88.097888,30.146096]]]}},
EOD;

// DECODING FAILS
$obj = json_decode($jso);
var_dump($obj);

// FIND OUT WHY DECODING FAILS
switch(json_last_error())
{
    case JSON_ERROR_NONE:             echo ' - No errors';
    break;
    case JSON_ERROR_DEPTH:            echo ' - Maximum stack depth exceeded';
    break;
    case JSON_ERROR_STATE_MISMATCH:   echo ' - Underflow or the modes mismatch';
    break;
    case JSON_ERROR_CTRL_CHAR:        echo ' - Unexpected control character found';
    break;
    case JSON_ERROR_SYNTAX:           echo ' - Syntax error, malformed JSON';
    break;
    case JSON_ERROR_UTF8:             echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
    break;
    case JSON_ERROR_RECURSION:        echo ' - One or more recursive references in the value to be encoded';
    break;
    case JSON_ERROR_INF_OR_NAN:       echo ' - One or more NAN or INF values in the value to be encoded';
    break;
    case JSON_ERROR_UNSUPPORTED_TYPE: echo ' - A value of a type that cannot be encoded was given';
    break;
    default:                          echo ' - Unknown error';
    break;
}

Open in new window

0
 

Author Comment

by:brucegust
ID: 40339656
So, going back to my task, here's what things start to look like once you start incorporating some indents:

{
      "id": "tag:search.twittercom, 2005:389903668427763712",
      "objectType": "activity",
      "actor": {
            "objectType": "persno",
            "id": "id:twitter.com:91239297",
            "link": "http://www.twiter.com/OGkush103",
            "displayName": "WalkingLick74",
            "postedTime": "2009-11-20T01:21:39.000Z",
            "image": "https://si0.twimg.com/profile_images/378800000593715086/755411d8bdc495472c2d7ed50e319582_normal.jpeg",
            "summary": "Self-Made, Self Paid..... I always had the mind to get it like a man, head first buot my young Ean! #YOLO",

I get it! Now, I'm looking at this: http://konklone.io/json/ That looks like what I need to do, but what's the best approach? Do you use PHP to parse it out and then create a CSV file? How do you get it done?
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40339722
If you want to post the complete and correct JSON string, I'll be glad to show you how we handle these things.  Except for the very simplest JSON strings, you cannot assume it's possible to turn JSON into a CSV because JSON is hierarchical and CSV is more-or-less a flat file format, with no hierarchy.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 375 total points
ID: 40339734
Here's a simplified example.

<?php // demo/temp_brucegust.php
error_reporting(E_ALL);
echo '<pre>';

// REF http://json.org/
// REF http://php.net/manual/en/json.constants.php
// REF http://php.net/manual/en/function.json-decode.php
// REF http://php.net/manual/en/function.json-encode.php
// REF http://php.net/manual/en/function.json-last-error.php
// REF http://php.net/manual/en/function.json-last-error-msg.php

// SEE TEST DATA AT http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28523915.html
$jso = <<<EOD
{
    "id": "tag:search.twittercom, 2005:389903668427763712",
    "objectType": "activity",
    "actor":
    {
        "objectType": "persno",
        "id": "id:twitter.com:91239297",
        "link": "http://www.twiter.com/OGkush103",
        "displayName": "WalkingLick74"
    }
}
EOD;

// IF DECODING SUCCEEDS
$obj = json_decode($jso);
if ($obj)
{
    $x = $obj->objectType;
    $y = $obj->actor->displayName;
    echo PHP_EOL . "$x $y";
}

// IF DECODING FAILS?
if (!$obj) echo json_last_error_message();

function json_last_error_message()
{
    static $errors = array
    ( JSON_ERROR_NONE             => null
    , JSON_ERROR_DEPTH            => 'Maximum stack depth exceeded'
    , JSON_ERROR_STATE_MISMATCH   => 'Underflow or the modes mismatch'
    , JSON_ERROR_CTRL_CHAR        => 'Unexpected control character found'
    , JSON_ERROR_SYNTAX           => 'Syntax error, malformed JSON'
    , JSON_ERROR_UTF8             => 'Malformed UTF-8 characters, possibly incorrectly encoded'
// UNDEFINED BEFORE PHP 5.5
//    , JSON_ERROR_RECURSION        => 'One or more recursive references in the value to be encoded'
//    , JSON_ERROR_INF_OR_NAN       => 'One or more NAN or INF values in the value to be encoded'
//    , JSON_ERROR_UNSUPPORTED_TYPE => 'A value of a type that cannot be encoded was given'
    )
    ;
    $error = json_last_error();
    return array_key_exists($error, $errors)
    ? $errors[$error]
    : "Unknown error ({$error})"
    ;
}

Open in new window

0
 

Author Comment

by:brucegust
ID: 40339939
Ray, as always, thanks for your time and willingness to share you expertise.

I've attached what was sent to me as a txt file just so I could be certain I was getting everything to you.

Thanks!
sample-json.txt
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 375 total points
ID: 40339959
This will show you the whole thing.  The process of "parsing" is just the process of teasing out the contents of the various properties.

<?php // demo/temp_brucegust.php
error_reporting(E_ALL);
echo '<pre>';

// REF http://json.org/
// REF http://php.net/manual/en/json.constants.php
// REF http://php.net/manual/en/function.json-decode.php
// REF http://php.net/manual/en/function.json-encode.php
// REF http://php.net/manual/en/function.json-last-error.php
// REF http://php.net/manual/en/function.json-last-error-msg.php

// SEE TEST DATA AT http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28523915.html#a40339939
$jso = <<<EOD
{"id":"tag:search.twitter.com,2005:389903668427763712","objectType":"activity","actor":{"objectType":"person","id":"id:twitter.com:91239297","link":"http://www.twitter.com/OGkush103","displayName":"WalkingLick74","postedTime":"2009-11-20T01:21:39.000Z","image":"https://si0.twimg.com/profile_images/378800000593715086/755411d8bdc495472c2d7ed50e319582_normal.jpeg","summary":"Self-Made, Self Paid..... I always had the mind to get it like a man, head first bout my younging Ean! #YOLO","links":[{"href":null,"rel":"me"}],"friendsCount":468,"followersCount":677,"listedCount":0,"statusesCount":25504,"twitterTimeZone":"Alaska","verified":false,"utcOffset":"-28800","preferredUsername":"OGkush103","languages":["en"],"location":{"objectType":"place","displayName":"Boston George Crib"},"favoritesCount":26},"verb":"post","postedTime":"2013-10-15T00:00:53.000Z","generator":{"displayName":"Twitter for iPhone","link":"http://twitter.com/download/iphone"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/OGkush103/statuses/389903668427763712","body":"You a killer you on twitter, You'n do NO talking","object":{"objectType":"note","id":"object:search.twitter.com,2005:389903668427763712","summary":"You a killer you on twitter, You'n do NO talking","link":"http://twitter.com/OGkush103/statuses/389903668427763712","postedTime":"2013-10-15T00:00:53.000Z"},"favoritesCount":0,"location":{"objectType":"place","displayName":"Mississippi, US","name":"Mississippi","country_code":"United States","twitter_country_code":"US","link":"https://api.twitter.com/1.1/geo/id/43d2418301bf1a49.json","geo":{"type":"Polygon","coordinates":[[[-91.65500899999999,30.146096],[-91.65500899999999,34.996099],[-88.097888,34.996099],[-88.097888,30.146096]]]}},"geo":{"type":"Point","coordinates":[31.99686058,-88.72688823]},"twitter_entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[]},"twitter_filter_level":"medium","twitter_lang":"en","retweetCount":0,"gnip":{"matching_rules":[{"tag":null}],"language":{"value":"en"}}}
EOD;

// IF DECODING SUCCEEDS
$obj = json_decode($jso);
if ($obj)
{
    // SHOW SOME PARTS OF THE OBJECT
    $x = $obj->objectType;
    $y = $obj->actor->displayName;
    echo PHP_EOL . "$x $y" . PHP_EOL;

    // SHOW THE ENTIRE OBJECT
    var_dump($obj);
}

// IF DECODING FAILS?
if (!$obj) echo json_last_error_message();

function json_last_error_message()
{
    static $errors = array
    ( JSON_ERROR_NONE             => null
    , JSON_ERROR_DEPTH            => 'Maximum stack depth exceeded'
    , JSON_ERROR_STATE_MISMATCH   => 'Underflow or the modes mismatch'
    , JSON_ERROR_CTRL_CHAR        => 'Unexpected control character found'
    , JSON_ERROR_SYNTAX           => 'Syntax error, malformed JSON'
    , JSON_ERROR_UTF8             => 'Malformed UTF-8 characters, possibly incorrectly encoded'
// UNDEFINED BEFORE PHP 5.5
//    , JSON_ERROR_RECURSION        => 'One or more recursive references in the value to be encoded'
//    , JSON_ERROR_INF_OR_NAN       => 'One or more NAN or INF values in the value to be encoded'
//    , JSON_ERROR_UNSUPPORTED_TYPE => 'A value of a type that cannot be encoded was given'
    )
    ;
    $error = json_last_error();
    return array_key_exists($error, $errors)
    ? $errors[$error]
    : "Unknown error ({$error})"
    ;
}

Open in new window

0
 

Author Closing Comment

by:brucegust
ID: 40340123
0
 
LVL 33

Expert Comment

by:Slick812
ID: 40340202
Sorry Posted after it was answered!
grettings brucegust, , I looked at the TEXT you have for this html JSON string, and you ask about the "parsing" of this string, This may be not so simple to figure out how and what to show as the "Parts" of this string to "chop out" and separate, as you have quite a mix of different types of sub-parts contents here, , ,

There are objects within objects, , and arrays within other objects, , and objects within arrays in other objects, , and there are arrays within arrays within arrays within objects in other places.
There may be very little that the several main object properties have in common to use a simple way to "Sort" out all of the parts of all of the objects and arrays in this thing and place in a single string, or a container, like an array.
in this JSON convert page you gave as  http://konklone.io/json/, I used your json text, and it gives a very "complex" parsing with parse segment IDs like "location/geo/type"

just to show how NON SIMPLE this can get, heres the function on that page that does their parsing -
function doCSV(json) {
    // 1) find the primary array to iterate over
    // 2) for each item in that array, recursively flatten it into a tabular object
    // 3) turn that tabular object into a CSV row using jquery-csv
    var inArray = arrayFrom(json);

    var outArray = [];
    for (var row in inArray)
        outArray[outArray.length] = parse_object(inArray[row]);

    $("span.rows.count").text("" + outArray.length);

    var csv = $.csv.fromObjects(outArray);
    // excerpt and render first 10 rows
    renderCSV(outArray.slice(0, excerptRows));
    showCSV(true);

    // show raw data if people really want it
    $(".csv textarea").val(csv);

    // download link to entire CSV as data
    // thanks to http://jsfiddle.net/terryyounghk/KPEGU/
    // and http://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side
    var uri = "data:text/csv;charset=utf-8," + encodeURIComponent(csv);
    $(".csv a.download").attr("href", uri);
  }

  // loads original pasted JSON from textarea, saves to anonymous gist
  // rate-limiting means this could easily fail with a 403.
  function saveJSON() {
    if (!input) return false;
    if (input == lastSaved) return false;

    // save a permalink to an anonymous gist
    var gist = {
      description: "test",
      public: true,
      files: {
        "source.json": {
            "content": input
        }
      }
    };

Open in new window

this has several more functions inside of it, and may take a large amount of time to convert to PHP.

Can you give us some Reason and-or Goal, that needs to be acomplished to have a Result to use on your page, with parts of this jason string displayed? ?
0
 

Author Comment

by:brucegust
ID: 40340259
Hey, Slick!

I appreciate you reaching out even after the question was answered!

The ultimate goal is to do this:

upload the json.gz file using some kind of interface

Take a look at the question I've got posted here: http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28524113.html. I'm not sure if I would use an "upload" dynamic or a enter the name of the file into a text field, but that's the first step I'm envisioning.

parse it out

You're right in that it's not an easily discernible file, but you've seen what it can and should look like based on your having said you've been out to http://konklone.io/json/ (that's a cool little interface, btw).

identify seven specific fields

I need actor/id, actor/displayName, actor/postedTime, generator/displayName, geo/type, geo/coordinates/0, geo/coordinates/1

export those four column names / data out as a csv file

Right now, I've gotten as far as uncompressing the file using this script:

 //This input should be from somewhere else, hard-coded in this example
$file_name = '00_8ptcd6jgjn201311060000_day.json.gz';
// Raising this value may increase performance
$buffer_size = 4096; // read 4kb at a time
$out_file_name = str_replace('.gz', '', $file_name); 
// Open our files (in binary mode)
$file = gzopen($file_name, 'rb');
$out_file = fopen($out_file_name, 'wb'); 
// Keep repeating until the end of the input file
while(!gzeof($file)) {
// Read buffer-size bytes
// Both fwrite and gzread and binary-safe
  fwrite($out_file, gzread($file, $buffer_size));
}  
// Files are done, close files
fclose($out_file);
gzclose($file);

Open in new window


Not entirely sure where to go from here, but that's the scope of the project.
0
 
LVL 33

Expert Comment

by:Slick812
ID: 40342742
???
I am not sure, but after a Question is answered here at EE, it is considered Incorrect to ask for more "unrelated" information to that question, as you now want a comma separated value parse of the JSON stuff in your string.

I can do CSV from a JSON array, but this question is now answered?

I went to your other question about  "upload" dynamic", however the part about "How can I put those two things together",, does not make any sense to me, sorry, you may need to rework that question to something that has more understandable terminology, as not many other experts have commented there, or even asked questions.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now