{"id":14069042,"url":"https://github.com/leeper/csvy","last_synced_at":"2025-03-17T01:30:52.529Z","repository":{"id":56937187,"uuid":"63156431","full_name":"leeper/csvy","owner":"leeper","description":"Import and Export CSV Data With a YAML Metadata Header","archived":false,"fork":false,"pushed_at":"2020-06-11T18:44:22.000Z","size":80,"stargazers_count":57,"open_issues_count":15,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-11T18:12:15.594Z","etag":null,"topics":["cran","csv","csvy","data","r","yaml"],"latest_commit_sha":null,"homepage":null,"language":"R","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/leeper.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-12T12:34:12.000Z","updated_at":"2024-04-29T01:02:54.000Z","dependencies_parsed_at":"2022-08-21T06:50:09.686Z","dependency_job_id":null,"html_url":"https://github.com/leeper/csvy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fcsvy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fcsvy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fcsvy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2Fcsvy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leeper","download_url":"https://codeload.github.com/leeper/csvy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835942,"owners_count":20355611,"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":["cran","csv","csvy","data","r","yaml"],"created_at":"2024-08-13T07:06:33.931Z","updated_at":"2025-03-17T01:30:51.951Z","avatar_url":"https://github.com/leeper.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# Import and Export CSV Data With a YAML Metadata Header\n\nCSVY is a file format that combines the simplicity of CSV (comma-separated values) with the metadata of other plain text and binary formats (JSON, XML, Stata, etc.). The [CSVY file specification](http://csvy.org/) is simple: place a YAML header on top of a regular CSV. The yaml header is formatted according to the [Table Schema](https://frictionlessdata.io/specs/table-schema/) of a [Tabular Data Package](https://frictionlessdata.io/specs/tabular-data-package/).\n\nA CSVY file looks like this:\n\n```\n#---\n#profile: tabular-data-resource\n#name: my-dataset\n#path: https://raw.githubusercontent.com/csvy/csvy.github.io/master/examples/example.csvy\n#title: Example file of csvy \n#description: Show a csvy sample file.\n#format: csvy\n#mediatype: text/vnd.yaml\n#encoding: utf-8\n#schema:\n#  fields:\n#  - name: var1\n#    type: string\n#  - name: var2\n#    type: integer\n#  - name: var3\n#    type: number\n#dialect:\n#  csvddfVersion: 1.0\n#  delimiter: \",\"\n#  doubleQuote: false\n#  lineTerminator: \"\\r\\n\"\n#  quoteChar: \"\\\"\"\n#  skipInitialSpace: true\n#  header: true\n#sources:\n#- title: The csvy specifications\n#  path: http://csvy.org/\n#  email: ''\n#licenses:\n#- name: CC-BY-4.0\n#  title: Creative Commons Attribution 4.0\n#  path: https://creativecommons.org/licenses/by/4.0/\n#---\nvar1,var2,var3\nA,1,2.0\nB,3,4.3\n```\n\nWhich we can read into R like this:\n\n\n```{r}\nlibrary(\"csvy\")\nstr(read_csvy(system.file(\"examples\", \"example1.csvy\", package = \"csvy\")))\n```\n\nOptional comment characters on the YAML lines make the data readable with any standard CSV parser while retaining the ability to import and export variable- and file-level metadata. The CSVY specification does not use these, but the csvy package for R does so that you (and other users) can continue to rely on `utils::read.csv()` or `readr::read_csv()` as usual. The `import()` function in [rio](https://cran.r-project.org/package=rio) supports CSVY natively.\n\n### Export\n\nTo create a CSVY file from R, just do:\n\n```{r}\nlibrary(\"csvy\")\nlibrary(\"datasets\")\nwrite_csvy(iris, \"iris.csvy\")\n```\n\nIt is also possible to export the metadata to separate YAML or JSON file (and then also possible to import from those separate files) by specifying the `metadata` field in `write_csvy()` and `read_csvy()`.\n\n### Import\n\nTo read a CSVY into R, just do:\n\n```{r}\nd1 \u003c- read_csvy(\"iris.csvy\")\nstr(d1)\n```\n\nor use any other appropriate data import function to ignore the YAML metadata:\n\n```{r}\nd2 \u003c- utils::read.table(\"iris.csvy\", sep = \",\", header = TRUE)\nstr(d2)\n```\n\n```{r, echo=FALSE}\nunlink(\"iris.csvy\")\n```\n\n## Package Installation\n\nThe package is available on [CRAN](https://cran.r-project.org/package=csvy) and can be installed directly in R using:\n\n```R\ninstall.packages(\"csvy\")\n```\n\nThe latest development version on GitHub can be installed using **devtools**:\n\n```R\nif(!require(\"remotes\")){\n    install.packages(\"remotes\")\n}\nremotes::install_github(\"leeper/csvy\")\n```\n\n[![CRAN Version](http://www.r-pkg.org/badges/version/csvy)](https://cran.r-project.org/package=csvy)\n![Downloads](http://cranlogs.r-pkg.org/badges/csvy)\n[![Travis-CI Build Status](https://travis-ci.org/leeper/csvy.png?branch=master)](https://travis-ci.org/leeper/csvy)\n[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/sgttgdfcql63578u?svg=true)](https://ci.appveyor.com/project/leeper/csvy)\n[![codecov.io](http://codecov.io/github/leeper/csvy/coverage.svg?branch=master)](http://codecov.io/github/leeper/csvy?branch=master)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeper%2Fcsvy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleeper%2Fcsvy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeper%2Fcsvy/lists"}