{"id":15608757,"url":"https://github.com/hypercubed/angular-dsv","last_synced_at":"2025-04-28T11:47:44.293Z","repository":{"id":17819997,"uuid":"20718573","full_name":"Hypercubed/angular-dsv","owner":"Hypercubed","description":"angularjs $http for tabular data","archived":false,"fork":false,"pushed_at":"2016-10-13T12:49:39.000Z","size":49,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T03:49:10.118Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/Hypercubed/angular-dsv","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hypercubed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-11T08:49:12.000Z","updated_at":"2016-09-28T10:00:40.000Z","dependencies_parsed_at":"2022-08-30T16:01:17.499Z","dependency_job_id":null,"html_url":"https://github.com/Hypercubed/angular-dsv","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fangular-dsv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fangular-dsv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fangular-dsv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fangular-dsv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hypercubed","download_url":"https://codeload.github.com/Hypercubed/angular-dsv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251309836,"owners_count":21568913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T05:22:07.503Z","updated_at":"2025-04-28T11:47:44.272Z","avatar_url":"https://github.com/Hypercubed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# angular-dsv [![Bower version](https://badge.fury.io/bo/angular-dsv.png)](http://badge.fury.io/bo/angular-dsv)\r\ndelimter-seperated-values\r\n\r\nA angularjs service for reading tabular data from text files; for example tab-delimited and comma-delimited.  angular-dsv combines the convenience of the [d3 csv/tsv module](https://github.com/mbostock/d3/wiki/CSV) with angular's [$http](https://docs.angularjs.org/api/ng/service/$http) service.  angular-dsv is RFC4180-compliant and dependent only on angular itself.\r\n\r\n## Install\r\n1. `bower install angular-dsv` or `bower install Hypercubed/angular-dsv`\r\n2. Include the `angular-dsv.js` into your app.  By default at `bower_components/angular-dsv/angular-dsv.js`.\r\n4. Add `hc.dsv` as a module dependency to your app.\r\n\r\n## Usage\r\n\r\n### dsv(delimiter)\r\n\r\nThe dsv service takes a single argument and returns a new `$http`-like service for handling text files of `delimiter`-seperated values.  `dsv.tsv` and `dsv.csv` are  shortcuts for `dsv('\\t')` and `dsv(',')` respectively.\r\n\r\n### dsv.tsv(config[, accessor])\r\n\r\nThe `dsv.tsv` service is an example of 'delimiter'-seperated value interface for tab-delimited tables.  It is service which takes two arguments: a configuration object like that expected by angular's [$http](https://docs.angularjs.org/api/ng/service/$http), and an optional accessor function for transforming each row of the tabular data file.  Like `$http` `dsv.tsv` returns a promise:\r\n\r\n```(js)\r\n  dsv.tsv({method: 'GET', url: '/someUrl'}, function(d) { return {key: d.key, value: +d.value}; })\r\n    .then(function(response) {\r\n      console.log(response.data);\r\n      // this callback will be called asynchronously\r\n      // when the response is available\r\n    })\r\n    .catch(function(err) {\r\n      // called asynchronously if an error occurs\r\n      // or server returns response with an error status.\r\n    });\r\n```\r\n\r\nThe data value is array of objects representing the parsed rows returned from the specified url.  The first row of the returned data is used as column names; these column names become the attributes on the returned objects. For example if the http request returns:\r\n\r\n```\r\nYear  Make     Model  Length\r\n1997  Ford     E350   2.34\r\n2000  Mercury  Cougar 2.38\r\n```\r\n\r\nThe resulting JavaScript array is:\r\n\r\n```\r\n[\r\n  {\"Year\": \"1997\", \"Make\": \"Ford\", \"Model\": \"E350\", \"Length\": \"2.34\"},\r\n  {\"Year\": \"2000\", \"Make\": \"Mercury\", \"Model\": \"Cougar\", \"Length\": \"2.38\"}\r\n]\r\n```\r\n\r\n#### dsv.tsv.get(url\\[, config]\\[, accessor])\r\n\r\nLike `$http` `dsv.tsv` provides a shortcut method for HTTP GET:\r\n\r\n```(js)\r\ndsv.tsv.get('/someUrl', accessorFunction).then(successCallback);\r\n```\r\n\r\n#### dsv.tsv.getRows(url\\[, config]\\[, accessor])\r\n\r\nSimilar to the `dsv.tsv.get` shortcut except the returned value is an array of arrays and the header line is treated as a standard row. For example if the http request returns:\r\n\r\n```\r\nYear  Make     Model  Length\r\n1997  Ford     E350   2.34\r\n2000  Mercury  Cougar 2.38\r\n```\r\n\r\nThe resulting JavaScript array is:\r\n\r\n```\r\n[\r\n  [\"Year\", \"Make\", \"Model\", \"Length\"],\r\n  [\"1997\", \"Ford\", \"E350\", \"2.34\"],\r\n  [\"2000\", \"Mercury\", \"Cougar\", \"2.38\"]\r\n]\r\n```\r\n\r\n### dsv.csv\r\n\r\nLike `dsv.tsv` except for comma-seperated-values.\r\n\r\n## Testing\r\n\r\nInstall npm and bower dependencies:\r\n\r\n```bash\r\n\tnpm install\r\n\tbower install\r\n\tnpm test\r\n```\r\n\r\n## Acknowledgments\r\n\r\nPreviously portions of this code were taken from mbostock's [d3 csv/tsv module](https://github.com/mbostock/d3/wiki/CSV).  Now using [d3-dsv](https://github.com/d3/d3-dsv).\r\n\r\n## License\r\nMIT\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Fangular-dsv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypercubed%2Fangular-dsv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Fangular-dsv/lists"}