Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Socrata API method to get the row count of a dataset?

Tags:

socrata

Is there any fast way to get the number of rows in a dataset?

The best idea I can come up with is to do binary probing using $limit and $offset, or maybe some hybrid of binary probing and a final fetch of a single column within a $limit/$offset window when the size is known within, say, 100 or so.

(I checked the HTTP headers... no joy.)

like image 547
Ed Staub Avatar asked Jan 07 '15 15:01

Ed Staub


People also ask

How do you count the number of rows in a dataset?

Use the COUNT aggregate function to count the number of rows in a table. This function takes the name of the column as its argument (e.g., id ) and returns the number of rows for this particular column in the table (e.g., 5).

What is a soda API?

Simple Oracle Document Access (SODA) is a set of NoSQL-style APIs that let you create and store collections of documents (in particular JSON) in Oracle Database, retrieve them, and query them, without needing to know Structured Query Language (SQL) or how the documents are stored in the database.

What is Socrata Open Data?

The Socrata Open Data API allows you to programmatically access a wealth of open data resources from governments, non-profits, and NGOs around the world.


1 Answers

One way you can achieve this is by doing a COUNT(*) operation on the dataset. For example, to get the total row count of this Socrata dataset:
https://data.seattle.gov/City-Business/Sold-Fleet-Equipment/y6ef-jf2w

You could issue this SODA query:
https://data.seattle.gov/resource/y6ef-jf2w.json?$select=count(*)

like image 105
Adrian Laurenzi Avatar answered Sep 21 '22 01:09

Adrian Laurenzi