...
- Fetching and Filtering: https://developer.c3.ai/docs/7.12.0/topic/tutorial-fetching-and-filtering
- Fetch and Filter Basics: https://developer.c3.ai/docs/7.12.0/topic/console-data-exploration-fetch-and-filters
- Fetch and Filter Advanced: https://developer.c3.ai/docs/7.12.0/topic/console-fetch-and-filters-advanced
Users can also provide a FetchSpec (or parameters) to the 'fetch' method to describe particular data to retrieve (e.g., only retrieve gene sequences collected in Germany). The FetchSpec can be 'empty' (e.g., OutbreakLocation.fetch()), or contain several parameters to return a subset of the data.
...
Note: Please see this C3.ai Developer Documentation for full list of FetchSpec parameters: https://developer.c3.ai/docs/7.12.17/type/FetchSpec
Examples of Fetch Calls
Consider As an example, please see the DTI housing example located Housing Coverage Example here: https://github.com/c3aidti/HouseCoverageExample
In this example, the BlockInfo Type BlockInfo defines contains information aggregated about census blocks. We can for example, fetch BlockInfo types fetch BlockInfo records, for which the 'prp_bf_lr' property is defined. Then we can order them based on field exists (i.e., is not null). We can also retrieve these records in descending order by their 'id' properly.
Code Block | ||
---|---|---|
| ||
BlockInfo.fetch({ 'limit': -1, 'filter': 'exists(prp_bf_lr)', 'order': 'descending(id)', 'include': 'pct_i_l,pct_t_l,prp_res_lr,pop10_ha_lr,hu10_ha_lr,eroom_ha_lr,med10_age,prp_bf_lr', }) |
Here's how you would perform the same fetch in pythonYou can run this same fetch in Python:
Code Block | ||
---|---|---|
| ||
raw_data = c3.BlockInfo.fetch(spec={ 'limit': -1, 'filter': 'exists(prp_bf_lr)', 'order': 'descending(id)', 'include': 'pct_i_l,pct_t_l,prp_res_lr,pop10_ha_lr,hu10_ha_lr,eroom_ha_lr,med10_age,prp_bf_lr' }) |
Another useful fetch command is fetchCount. This function is nearly identical to the fetch commands above, but it just returns a count of the number of objects which match the fetch filter. This is useful when trying to determine whether a given search is refined enough.
In the Javascript Console this is:
Code Block |
---|
BlockInfo.fetchCount({'filter': 'exists(prp_bf_lr)'}) |
The same in python is:
Code Block |
---|
c3.BlockInfo.fetchCount(spec={'filter': 'exists(prp_bf_lr)'}) |
...
Additional details on "Fetching in Python" are available in this C3.ai Developer Documentation: https://developer.c3.ai/docs/7.12.0/topic/ds-jupyter-notebooks
Additional examples of fetch calls can be found in our examples here:
- https://github.com/c3aidti/casesExample
- https://github.com/c3aidti/genomicsExample
- https://github.com/c3aidti/HouseCoverageExample
- https://github.com/c3aidti/VaccineListing
- https://github.com/c3aidti/casesExample
- https://github.com/c3aidti/genomicsExample
- https://github.com/c3aidti/HouseCoverageExample
- https://github.com/c3aidti/VaccineListing
- https://github.com/c3aidti/EpidemiologyExample
Here is a list of C3 documentation mentioning fetching:
...
Another useful fetch command is fetchCount. This function is nearly identical to the fetch commands above, but it just returns a count of the number of objects which match the fetch filter. This is useful when trying to determine whether a given search is refined enough.
In the Javascript Console this is:
Code Block |
---|
BlockInfo.fetchCount({'filter': 'exists(prp_bf_lr)'}) |
The same in python is:
Code Block |
---|
c3.BlockInfo.fetchCount(spec={'filter': 'exists(prp_bf_lr)'}) |
...
Converting Fetch results to usable forms in Jupyter Notebook
...