Store Integer List on Stream

+1 vote
Hello,

I have a list of 7000 integers in resulting from a python script. I want to store it in stream but I am unable to find a solution for that. Could you please guide me on how could we do that ?

Thank You
asked May 10, 2017 by Varun

1 Answer

+1 vote
Assuming you want to store it in one stream item, convert each integer to 4 bytes of data represented as 8 hexadecimal characters (or 8 bytes / 16 characters if the integers might be really big) and concatenate them all together. These links will help you:

http://stackoverflow.com/questions/2269827/how-to-convert-an-int-to-a-hex-string

http://stackoverflow.com/questions/209513/convert-hex-string-to-int-in-python
answered May 10, 2017 by MultiChain
That is nice approach. However, what I want to do is, somehow index values inside a key. I have, for example, 7000 values under 1 key. Each value is a hexlified json structure. This json structure contains many attributes. One of them is "timestamp".

Now, I plan to develop a python script to retreive values based on a range of timestamp. For that I prepared a list of the timestamps from each value. This list essentially gives me the index no.--timestamp correlation.

Once I have an index no. specific to that timestamp, I can easily retrieve that value from stream using the index no.

Can you suggest some better arrangement to do the same ?
If I understand correctly, you want to be able to embed JSON documents inside a stream, and then search the stream for documents where a particular field has a particular value. If so, I'm afraid the answer is that you cannot do this, yet...
Yes, I know that, I however, devised another mechanism to do it. Now the problem is just that : I have a file of 50kb. Is there any way to store this file in multichain's stream ?
Yes, you can store files of up to 64 MB in a stream. It's just the value of the stream item.
Is it simple as "publish stream_name key filename_as_value" ?
Not the file name, the file contents.
...