Skip to content

Instantly share code, notes, and snippets.

@sckott
Last active December 19, 2015 09:59
Show Gist options
  • Select an option

  • Save sckott/5937553 to your computer and use it in GitHub Desktop.

Select an option

Save sckott/5937553 to your computer and use it in GitHub Desktop.

Revisions

  1. sckott revised this gist Jul 5, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions csvtoapi.md
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,12 @@ The code that does the conversion from csv to api is written in php, see here ht

    We just host their code on our hosted server at http://ropensci.org/

    Then we build the URL
    Then we build the URL (see bottom of page for possible arguments more generally)

    + The base url http://ropensci.org/csv-to-api/index.php
    + Then tack on the Dryad url http://datadryad.org/bitstream/handle/10255/dryad.34075/Evolution%2011-0308%20Pryke%20et%20al.%202011a.csv?sequence=1 (you can find this URL by right clicking on the csv file link on Dryad's site)
    + Then specify the source format, which is csv source_format=csv
    + Specify the output format format=json (could also be html, csv, xml)
    + Specify the output format format=json (could also be html, json, xml, default is json)
    + Then you can query on columns in the actual csv file. For example, there is a column called *Clutch* that has possible values *Y* and *N* Clutch=N
    + The full URL http://ropensci.org/csv-to-api/index.php?source=http://datadryad.org/bitstream/handle/10255/dryad.34075/Evolution%2011-0308%20Pryke%20et%20al.%202011a.csv?sequence=1&source_format=csv&format=json&Clutch=N

  2. sckott revised this gist Jul 5, 2013. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions csvtoapi.md
    Original file line number Diff line number Diff line change
    @@ -38,10 +38,10 @@ Mean egg size: "204"

    ##### Possible parameters to use

    `source`: the URL to the source CSV
    `source_format`: if the url does not end in .csv, you should specify 'csv' here (to facilitate future functionality)
    `format`: the requested return format, either json, xml, or html (default json)
    `callback`: if JSON, an optional JSONP callback
    `sort`: field to sort by (optional)
    `sort_dir`: direction to sort, either asc or desc (default asc)
    any field(s): may pass any fields as a key/value pair to filter by
    + `source`: the URL to the source CSV
    + `source_format`: if the url does not end in .csv, you should specify 'csv' here (to facilitate future functionality)
    + `format`: the requested return format, either json, xml, or html (default json)
    + `callback`: if JSON, an optional JSONP callback
    + `sort`: field to sort by (optional)
    + `sort_dir`: direction to sort, either asc or desc (default asc)
    + any field(s): may pass any fields as a key/value pair to filter by
  3. sckott revised this gist Jul 5, 2013. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion csvtoapi.md
    Original file line number Diff line number Diff line change
    @@ -34,4 +34,14 @@ Clutch: "N",
    Mean egg size: "204"
    },
    ...continued...
    ```
    ```

    ##### Possible parameters to use

    `source`: the URL to the source CSV
    `source_format`: if the url does not end in .csv, you should specify 'csv' here (to facilitate future functionality)
    `format`: the requested return format, either json, xml, or html (default json)
    `callback`: if JSON, an optional JSONP callback
    `sort`: field to sort by (optional)
    `sort_dir`: direction to sort, either asc or desc (default asc)
    any field(s): may pass any fields as a key/value pair to filter by
  4. sckott created this gist Jul 5, 2013.
    37 changes: 37 additions & 0 deletions csvtoapi.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    #### Description of csv to api

    The code that does the conversion from csv to api is written in php, see here https://github.com/project-open-data/csv-to-api

    We just host their code on our hosted server at http://ropensci.org/

    Then we build the URL

    + The base url http://ropensci.org/csv-to-api/index.php
    + Then tack on the Dryad url http://datadryad.org/bitstream/handle/10255/dryad.34075/Evolution%2011-0308%20Pryke%20et%20al.%202011a.csv?sequence=1 (you can find this URL by right clicking on the csv file link on Dryad's site)
    + Then specify the source format, which is csv source_format=csv
    + Specify the output format format=json (could also be html, csv, xml)
    + Then you can query on columns in the actual csv file. For example, there is a column called *Clutch* that has possible values *Y* and *N* Clutch=N
    + The full URL http://ropensci.org/csv-to-api/index.php?source=http://datadryad.org/bitstream/handle/10255/dryad.34075/Evolution%2011-0308%20Pryke%20et%20al.%202011a.csv?sequence=1&source_format=csv&format=json&Clutch=N

    ```
    {
    29: {
    Nest number: "118",
    Female morph: "black",
    Pre_exp weight: "12.8",
    Parental diet: "HQ",
    Exp weight: "12.8",
    Clutch: "N",
    Mean egg size: "214"
    },
    58: {
    Nest number: "113",
    Female morph: "red",
    Pre_exp weight: "14.2",
    Parental diet: "HQ",
    Exp weight: "14.2",
    Clutch: "N",
    Mean egg size: "204"
    },
    ...continued...
    ```