You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79-19Lines changed: 79 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,9 @@ The main function is `get_nass`, which queries the main USDA Quick Stats databas
53
53
54
54
The `format` keyword can be added to the query after a semicolon `;` and defines the format of the response. It is set to `JSON` as a default, other formats provided by the database are `CSV` and `XML`.
55
55
56
-
The function returns a DataFrame with the requested query for the `JSON` and `CSV` formats, no DataFrame has been implemented for the `XML` format yet, PR's welcome.
56
+
The function returns a HTTP.request object and the user can parse it using different packages, some examples below.
57
57
58
-
In the following example, the survey data for oranges in California (CA) for the year 2019 was queried for information about the headers "ACRES BEARING" and "PRICE RECEIVED".
58
+
In the following example, the survey data for oranges in California (CA) for the year 2019 was queried for information about the headers "ACRES BEARING" and "PRICE RECEIVED". The format keyword isn't specified, so the request will return a JSON file.
59
59
60
60
Notice that header values that have spaces in them need to be passed with the symbol `%20` replacing the space. In general, no spaces are allowed in the query.
{"data":[{"begin_code":"00","prodn_practice_desc":"ALL PRODUCTION PRACTICES","watershed_desc":"","state_fips_code":"06","commodity_desc":"ORANGES","statisticcat_desc":"AREA BEARING","Value":"147,000","watershed_code":"00000000","source_desc":"SURVEY","util_practice_desc":"ALL UTILIZATION PRACTICES","domaincat_desc":"NOT SPECIFIED","domain_desc":"TOTAL","state_alpha":"CA","week_ending":"","group_desc":"FRUIT & TREE NUTS","reference_period_desc":"YEAR","CV (%)":"","year":2019,"short_desc":"ORANGES - ACRES BEARING","country_code":"9000","load_time":"2019-08-28 15:09:57","country_name":"UNITED STATES","unit_desc":"ACRES","county_code":"","end_code":"00","sector_desc":"CROPS","state_name":"CALIFORNIA","zip_5":"","class_desc":"ALL CLASSES","county_ansi":"","asd_code":"","location_desc":"CALIFORNIA","congr_district_code":"","county_name":"","state_ansi":"06","region_desc":"","asd_desc":"","freq_desc":"ANNUAL","agg_level_desc":"STATE"},{"reference_period_desc":"MARKETING YEAR","CV (%)":"","yea
74
81
⋮
75
-
│ 274 │ ALL PRODUCTION PRACTICES │ CALIFORNIA │ UNITED STATES │ │ 00000000 │ 06 │ SURVEY │ CALIFORNIA │ PRICE RECEIVED │
76
-
│ 275 │ ALL PRODUCTION PRACTICES │ CALIFORNIA │ UNITED STATES │ │ 00000000 │ 06 │ SURVEY │ CALIFORNIA │ PRICE RECEIVED │
77
-
│ 276 │ ALL PRODUCTION PRACTICES │ CALIFORNIA │ UNITED STATES │ │ 00000000 │ 06 │ SURVEY │ CALIFORNIA │ PRICE RECEIVED │
82
+
274515-byte body
83
+
"""
78
84
```
79
85
86
+
This query object can be post-processed in different ways, depending on the format. One possible option is to return the query as a CSV file and read it into a DataFrame.
`get_param_values(arg)` is a helper query that allow user to check the values of a field `arg` from the database. This is useful when constructing different query strings, as it allows the user to determine which values are available on each field.
This query would fail if ran directly using the `get_nass` function, because it exceeds the limit of 50000 rows.
132
192
133
193
I would like to thank @markushhh, because I heavily used his [FredApi.jl](https://github.com/markushhh/FredApi.jl) for inspiration. And sometimes blatant plagiarism.
0 commit comments