Last active
July 31, 2020 10:09
-
-
Save hubgit/5488213 to your computer and use it in GitHub Desktop.
Revisions
-
hubgit revised this gist
Apr 30, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,12 +9,13 @@ )); $limit = 100000; $total = 860350; // SELECT COUNT(*) WHERE { ?x a <http://landregistry.data.gov.uk/def/ppi/TransactionRecord> } for ($i = 0; $i < $total; $i += $limit) { $query = sprintf(' SELECT ?postcode ?amount ?date ?status WHERE { ?transx a <http://landregistry.data.gov.uk/def/ppi/TransactionRecord> . ?transx <http://landregistry.data.gov.uk/def/ppi/pricePaid> ?amount . ?transx <http://landregistry.data.gov.uk/def/ppi/transactionDate> ?date . ?transx <http://landregistry.data.gov.uk/def/ppi/propertyAddress> ?addr. -
hubgit revised this gist
Apr 30, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ CURLOPT_HTTPHEADER => array('Accept: text/plain'), )); $limit = 100000; $total = 858848; // COUNT(*) for ($i = 0; $i < $total; $i += $limit) { -
hubgit revised this gist
Apr 30, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ $curl = curl_init('http://landregistry.data.gov.uk/landregistry/query'); curl_setopt_array($curl, array( CURLOPT_VERBOSE => true, CURLOPT_ENCODING => 'gzip,deflate', CURLOPT_HTTPHEADER => array('Accept: text/plain'), -
hubgit created this gist
Apr 30, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ <?php $curl = curl_init('http://landregistry.data.gov.uk/landregistry/query'); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => true, CURLOPT_VERBOSE => true, CURLOPT_ENCODING => 'gzip,deflate', CURLOPT_HTTPHEADER => array('Accept: text/plain'), )); $limit = 10000; $total = 858848; // COUNT(*) for ($i = 0; $i < $total; $i += $limit) { $query = sprintf(' SELECT ?postcode ?amount ?date ?status WHERE { ?transx <http://landregistry.data.gov.uk/def/ppi/pricePaid> ?amount . ?transx <http://landregistry.data.gov.uk/def/ppi/transactionDate> ?date . ?transx <http://landregistry.data.gov.uk/def/ppi/propertyAddress> ?addr. ?transx <http://landregistry.data.gov.uk/def/ppi/recordStatus> ?status. ?addr <http://landregistry.data.gov.uk/def/common/postcode> ?postcode . } LIMIT %d OFFSET %d', $limit, $i); $params = array( 'query' => $query, 'output' => 'csv', ); $file = gzopen(sprintf('data/%s.csv.gz', $i), 'w'); curl_setopt_array($curl, array( CURLOPT_POSTFIELDS => http_build_query($params), CURLOPT_FILE => $file, )); $result = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($code !== 200) { exit("Error: $code\n" . print_r($result, true)); } gzclose($file); }