Visokio website     Downloads     Video tutorials     KnowledgeBase  
Sources: How to unserialize php data? - Visokio Forums
Sources: How to unserialize php data?
  •     naruemon May 29, 2013 3:34AM
    Hi,

    One of our data sources is kept as serialized data from php serialize() function.

    The data is in the following format:
    a:3:{i:0;s:2:"74";i:1;s:3:"185";i:2;s:3:"151";} --> total data is 3 contains 74, 185, 151
    a:2:{i:0;s:3:"120";i:1;s:3:"119";} --> total data is 2 contains 120, 119
    The number of info in this format is vary from 1 - 200.

    I would like to get the data in easier format to manage. So I could use de-tokenize function to organize data. Do we have any function to manage this format of data? Thank you.
  • 14 Comments
  •     chris May 29, 2013 6:17AM
    Hi,

    Can you post an example of how you want the data to be shown inside Omniscope?
  •     naruemon May 29, 2013 8:03AM
    Current
    =====
    Location code
    Thailand a:3:{i:0;s:2:"74";i:1;s:3:"185";i:2;s:3:"151";}
    Hongkong a:2:{i:0;s:3:"120";i:1;s:3:"119";}

    The result could be:
    Location code
    Thailand 74, 185, 151
    Hongkong 120, 119

    After de-tokenize, the expected result is like the following:
    Location code
    Thailand 74
    Thailand 185
    Thailand 151
    Hongkong 120
    Hongkong 119
  •     chris May 29, 2013 12:35PM
    Hi,

    This is a fairly isolated data format, as such there isn't any easy way to read this into Omniscope directly. I would suggest writing a small program to format the data into CSV or some common format prior to reading it in.
  •     naruemon May 29, 2013 1:42PM
    Hi Chris,

    This data is kept in database and we tried to use Omniscope to analyse this data in realtime/scheduler. If we have to export the data from database and use some program to convert them, I am not sure how Omniscope could analyse this data in realtime?

    The data format is from php function which you can find the reference in the following:
    http://www.w3resource.com/php/function-reference/unserialize.php
  •     steve May 30, 2013 1:38AM
    I suggest using the SCRIPT function.
    Example
    JavaScript reference/guide
  •     steve June 1, 2013 9:17AM
    Solution attached. I found a Javascript equivalent of PHP unserialize, online, and used that. See the Custom Script block for details.
    Attachments
    unserialize.iok 12K
  •     steve June 1, 2013 9:17AM
  •     naruemon June 18, 2013 3:17AM
    Thank you Steve ^^
    Anyway, the iok file (in attached) has only the Omniscope block.
    Could you upload file which contain the operation block?
  •     steve June 19, 2013 4:06AM
    Are you using an old build of 2.8, or 2.7? You need 2.8 Beta.
  •     naruemon June 19, 2013 4:36AM
    I am using version 2.8.
    The attached is the result after I saved and open the file.
    Please suggest :D
    Attachments
    unserialized.png 103K
  •     chris June 19, 2013 5:02AM
    Hi,

    What version of 2.8 are you using? Can you ensure you have installed the latest version (b993). When you open the file you should see a "Custom script" block performing the transformation described by Steve above.
  •        daniel June 19, 2013 5:17AM
    I don't see the script either with 2.8 b 993
  •     chris June 19, 2013 6:54AM
    Hi,

    Can you try opening the attached file. Are you able to see the script now?
    Attachments
    unserialize (1).iok 16K
  •     naruemon June 20, 2013 1:14AM
    Thanks for the attached file.
    I can see the script now ^^

Welcome!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

Tagged