Crunch a spreadsheet with Python
Using the Cloud-RF API, you can process an entire spreadsheet of site data in one go to make a complete network coverage map.
This tutorial assumes you are a Windows or Mac user with minimal programming experience. It uses the free Python scripts available here.
Windows user? Don’t know Python?
Fear not, we have a script and tutorial for Windows spreadsheets processing here.
INSTALL PYTHON AND THE REQUESTS MODULE
Python is already present on a Mac but for Windows you need to install Python 2.7. Download the right package for your operating system from https://www.python.org/ftp/python/2.7/. You will also need the python requests module which you can install once python is installed with this command:
python.exe -m pip install requests
GET THE CLOUD-RF PYTHON SCRIPTS
Download the python scripts as a ZIP archive: https://github.com/Cloud-RF/CloudRF-API-clients/archive/master.zip.
The script we will use is called ‘calculate_and_mesh.py’ which uses several different API calls to process each row in a spreadsheet under a unique group name (network name), then it performs a mesh operation to merge the sites into a single coverage layer.
PREPARE YOUR SPREADSHEET
Your data needs to be in a basic comma separated CSV spreadsheet (known as MS-DOS CSV format in Microsoft Excel). The top row should be column headers defined at https://api.cloudrf.com. You can find an example CSV file called ‘demo_network.csv’ along with the python scripts.
Your UID and KEY values are unique to your CloudRF account and can be obtained once logged in at the ‘my balance’ page.
PROCESS YOUR DATA
Run the python script with one argument which is the name of CSV spreadsheet. You will see results appear in your terminal for each row. The final result will be the consolidated mesh. For the demo script and data, each run of the script will generate a new network name. This is necessary to stop you meshing lots of old files belonging to the same network when you might only want to mesh 10 new sites.
python calculate_and_mesh.py demo_network.csv
USE YOUR RESULTS
Everything you do is stored on the server. The demo script also pulls down a KMZ file for each calculation but if you want to see your finished result, login to the web interface at https://cloudrf.com/ui and open your archive. You will find your spreadsheet has become a coverage map.
You can use the data either in the web interface, download it from there as a KMZ, SHP or TIFF file. If you want to publish or share the data you can get a URL or HTML embed code to host the layer on your own website.
CHANGE AND REPEAT
Once you’ve got your result its quite common to wonder what effect a different parameter might have. To change a value for all columns, change it for the first row eg. set txw (Transmitter power in Watts) to 2 then copy that value into all the rows below. Save the CSV file and reprocess with the command as before. You will get a new network because the script uses a unique network name each time.
In your web archive you can then go and select the network with the old parameters and delete it by checking the box and clicking the trash can icon.
ALTERNATIVE LANGUAGES / SCRIPTS
curl --request POST
--header 'Content-Type: application/x-www-form-urlencoded'