Institute for Personal Robots in Education Blog

Distributed computing with Calico

This example shows off some of the new features in the latest Calico, version 2.3.5: you can programmatically create a spreadsheet, put data in it, collect data from other users, and make the data available on the web. This might be a way of collecting data in a classroom activity (perhaps measurements of some kind), or perhaps a multiplayer game. The program below is what the teacher might show on the screen, as it shows the spreadsheet as it changes as new data comes in from the student.

You can download the latest Calico from

# Example showing show to programmatically
# create a spreadsheet, and get data from
# distributed programs.

import time, random

calico.Open("Experiment1.csv")              # create a new file, and open it in the IDE
doc = calico.GetDocument("Experiment1.csv") # get the doc
# let's put in the Calico Cloud, so students can download
# it at any time from:
doc.inCloud = True
# now you could manipulate the spreadsheet programmatically
# this example receives data from distributed users:

doc[0][0] = "Average:"
doc[1][0] = 0.0
doc[2][0] = "Count:"
doc[3][0] = 0
count = 0
total = 0.0
calico.ReceiveData() # clear the queue
while True:
    # First add the data to the spreadsheet:
    data = calico.ReceiveData()
    received = False
    for message in data:
        from_name, from_data = message
        doc[0][count + 2] = from_name
        doc[1][count + 2] = from_data
        count += 1
        total += float(from_data)
        doc[1][0] = total/count
        doc[3][0] = count
        received = True
    if received:
    # Wait a bit:
    # send a sample message to myself representing some computation
    # in real usage, these would come from classmates:
    calico.SendData(calico.connection.user, str(random.random()))

Screenshot from 2013-05-12 11:19:42.png34.35 KB

Post new comment

  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
More information about formatting options