Turning array into a downloadable blob

Ok, with the help of this post I worked it out.
I basically serialised the array and created a blob of it, like this example :

  
  # Some dummy data.
  a = []
  for i in range(30):
    a.append({
      "ddi":i*1000,
      "calls":i+10,
      "mins":i*10*i-1
    })
    
  # serialise it for the sake of blobbing it.
  s = ""
  for d in a:
    s += str(d['ddi'])+","+str(d['calls'])+","+str(d['mins'])+"\n"
  
  # Blob it
  o=anvil.BlobMedia("text/csv",s)

Not sure how this scales to larger files, so any better ideas would be welcomed.

1 Like