I have Base64 encoded data from an experiment. So what I am trying to do in stepwise is:
- Retrieve bytes from base64 encoding (Decode it)
- Convert bytes to little-endian
- Decompress bytes from (zlib)
- Convert byte array to float array
Example:
Dn3LQ3np4kOyxQJE20kDRBRuFkScZB5ENxEzRFa+O0THMz9EOQRCRFC1QkRYeUNEwXJJROfbSUScvE5EVDtVRK5PV0TLUWNE481lRHX7ZkSBBWpE9FVyRIFdeESkoHhEnid8RI1nfUSy4YBE/C2CRGKQg0RcR4RE54uEROUAhUTBWodErKyMRNsVkkRvUpJEukWURO58lkSqRZ1E2VauRPBTwEQf9cVE9BnKRA==
What I have tried so far
import os
import base64
import struct
s = 'Dn3LQ3np4kOyxQJE20kDRBRuFkScZB5ENxEzRFa+O0THMz9EOQRCRFC1QkRYeUNEwXJJROfbSUScvE5EVDtVRK5PV0TLUWNE481lRHX7ZkSBBWpE9FVyRIFdeESkoHhEnid8RI1nfUSy4YBE/C2CRGKQg0RcR4RE54uEROUAhUTBWodErKyMRNsVkkRvUpJEukWURO58lkSqRZ1E2VauRPBTwEQf9cVE9BnKRA=='
decode=base64.decodestring(s)
tmp_size=len(decode)/4
Now I am trying to convert these byte to little endian from here.
I want to do the next operation in Python.
I am trying to figure it out myself but, it is taking too much time.
Thanks!
It appears your data isn’t actually compressed. Read the data as floats either in a loop using
struct.unpack_from()or as one big structure usingstruct.unpack().If the data is compressed, decompress it.