Data from pplapi can be loaded into NetLogo in several ways:
If you choose to use live API data, this will result in your simulations using different agent data each time. NetLogo will require two extensions in order to smoothly integrate: web and csv. See below for help installing these extensions.
extensions [ web csv ]
breed [ agents agent ]
agents-own [ id id_str country_name country_tld sex age date_of_birth latitude
longitude income internet language religion openness conscientiousness extraversion
agreeableness neuroticism ]
to get-pplapi-sample
let filename "sample.csv"
file-close-all
file-delete filename
web:download-file "http://pplapi.com/batch/500/sample.csv" filename
file-open filename
while [not file-at-end?] [
let row csv:from-row file-read-line
if (item 0 row) != "id" [ ;; skip the header row
create-agents 1 [
set id (item 0 row)
set id_str (item 1 row)
set country_name (item 2 row)
set country_tld (item 3 row)
set sex (item 4 row)
set age (item 5 row)
set date_of_birth (item 6 row)
set latitude (item 7 row)
set longitude (item 8 row)
set income (item 9 row)
set internet (item 10 row)
set language (item 11 row)
set religion (item 12 row)
set openness (item 13 row)
set conscientiousness (item 14 row)
set extraversion (item 15 row)
set agreeableness (item 16 row)
set neuroticism (item 17 row)
]
]
]
end
One consequence of the live API is that you may retrieve a maximum of 500 agents per API request. Because you may make up to 6 requests per minute, this means your simulations will typically involve 3000 or fewer agents.
This will result in your simulations always using the same data for every simulation run. Because you may build up a large archive of sample data over the course of hours or days, there is no practical limit to the size of the simulation you can attempt with archived pplapi.com data.
The full list of NetLogo extensions is available here. You can directly download web.zip and csv.zip. After you have unzipped them, copy all of the .jar files into your Netlogo 5.x/extensions folder. In my case, NetLogo is installed to my Applications folder so I copy the .jar files to /Applications/Netlogo 5.x/extensions.
The following works on my OS X computer:
unzip csv-*.zip web-*.zip
mv *.jar "/Applications/Netlogo 5.3/extensions"
The NetLogo Web Extension enables your simulation to make requests to web resources for data. Because pplapi.com provides data as a web resource, this extension is perfect for integrating pplapi.com data into your simulations. Download the Web Extension here.
The NetLogo CSV Extension simplifies the process of loading CSV data from a file. Although it is easy enough to perform this task manually using NetLogo, it is just easier to use this extension. Download the CSV Extension here.