2

I am trying to find a list of all US universities and colleges for my Ph.D. project. I have downloaded the scorecard data; however, it is missing major universities, like Brown, the Univeristy of California, and the Univeristy of Texas... and many more.

Any help would be appreciated.

Nicolas Raoul
  • 8,426
  • 5
  • 28
  • 61

1 Answers1

0

I believe almost all universities and colleges are in Wikidata, so you can query it:

SELECT DISTINCT ?item ?itemLabel 
WHERE 
{
  {
    ?item p:P31/ps:P31/wdt:P279* wd:Q3918. # University or subclass
  }
  UNION {
    ?item p:P31/ps:P31/wdt:P279* wd:Q189004. # College or subclass
  }
  ?item wdt:P17 wd:Q30. # USA

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }

https://w.wiki/7JP$

This currently gets me 4319 results in 8 seconds.

There may be duplicates or near-duplicates, for instance a university that contains a college or other special cases.

Nicolas Raoul
  • 8,426
  • 5
  • 28
  • 61
  • Thank you very much.

    Would it be possible to get a list of whether they are public or private? or maybe the town they are located in?

    – Alanoud Naif Aug 24 '23 at 09:10
  • @AlanoudNaif: Yes, you can probably add optional properties for the city, and get the name of the class for public/private. See the usage of OPTIONAL {?QID wdt:P131 ?cityQID. ?cityQID rdfs:label ?city. FILTER (lang(?city) = "en").} and ?QID p:P31/ps:P31 ?typeQID. ?typeQID wdt:P279* wd:Q3918. ?typeQID rdfs:label ?type. FILTER (lang(?type) = "en"). at https://github.com/database-of-embassies/database-of-embassies/blob/master/tools/generate_csv/pois_for_operator.sparql for inspiration. – Nicolas Raoul Aug 24 '23 at 10:22
  • When I run it, it gives me the following error message: Query is malformed: Encountered " "optional" "OPTIONAL "" at line 14, column 1. – Alanoud Naif Aug 24 '23 at 10:38
  • this is the code I inserted:

    SELECT DISTINCT ?item ?itemLabel WHERE { { ?item p:P31/ps:P31/wdt:P279* wd:Q3918. # University or subclass } UNION { ?item p:P31/ps:P31/wdt:P279* wd:Q189004. # College or subclass } ?item wdt:P17 wd:Q30. # USA

    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } OPTIONAL {?QID wdt:P131 ?cityQID. ?cityQID rdfs:label ?city. FILTER (lang(?city) = "en").

    ?QID p:P31/ps:P31 ?typeQID. ?typeQID wdt:P279* wd:Q3918. ?typeQID rdfs:label ?type. FILTER (lang(?type) = "en").}

    – Alanoud Naif Aug 24 '23 at 12:10
  • You may want to ask at https://www.wikidata.org/wiki/Wikidata:Request_a_query Please say exactly what you want to achieve, and post your current full query, even if it does not work. – Nicolas Raoul Aug 25 '23 at 01:41