Skip to content

dataService.loadPackage

Jayson Harshbarger edited this page Oct 6, 2016 · 1 revision

The dataService.loadPackage method loads and processes JSON dataPackage files. Processing includes normalising the package URLs and loading parsing resources with known file types. For example, if the following dataPackage file is loaded using the dataService.loadPackage method

{
  "name": "Letters",
  "title": "Cryptological Mathematics, Robert Lewand.",
  "description": "Relative frequencies of the letters in the English language",
  "resources": [
    "letters.tsv"
  ],
  "image": "thumbnail.png",
  "readme": "README.md"
}

the resulting JS object will be:

{
  "name": "Letters",
  "title": "Cryptological Mathematics, Robert Lewand.",
  "description": "Relative frequencies of the letters in the English language",
  "resources": [
    {
      "name": "letters.tsv",
      "path": "letters.tsv",
      "format": "tsv",
      "url": "components/examples/bars/letters.tsv",
      "mediatype": "text/tab-separated-values",
      "content": "letter\tfrequency\nA\t.08167\nB\t.01492\nC\t.02780\n",
      "data": [
        {
          "letter": "A",
          "frequency": ".08167"
        },
        {
          "letter": "B",
          "frequency": ".01492"
        },
        {
          "letter": "C",
          "frequency": ".02780"
        }
      ],
      "errors": [],
      "meta": {
        "delimiter": "\t",
        "linebreak": "\n",
        "aborted": false,
        "truncated": false,
        "cursor": 251,
        "fields": [
          "letter",
          "frequency"
        ]
      }
    }
  ],
  "image": "components/examples/bars/thumbnail.png",
  "readme": "components/examples/bars/README.md",
  "base": "components/examples/bars/"
}