{"id":22966629,"url":"https://github.com/favstats/appendornot","last_synced_at":"2025-08-13T09:33:29.746Z","repository":{"id":108349510,"uuid":"570564215","full_name":"favstats/appendornot","owner":"favstats","description":"The goal of appendornot is to provide easy access to writing and appending csv or text files.","archived":false,"fork":false,"pushed_at":"2024-01-06T21:49:22.000Z","size":34,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-01-06T22:31:06.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/favstats.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-11-25T13:49:57.000Z","updated_at":"2022-12-01T21:48:40.000Z","dependencies_parsed_at":"2023-05-21T23:00:40.915Z","dependency_job_id":null,"html_url":"https://github.com/favstats/appendornot","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fappendornot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fappendornot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fappendornot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fappendornot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/favstats","download_url":"https://codeload.github.com/favstats/appendornot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229754831,"owners_count":18119131,"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-12-14T20:44:53.202Z","updated_at":"2025-08-13T09:33:29.703Z","avatar_url":"https://github.com/favstats.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# appendornot\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![CRAN status](https://www.r-pkg.org/badges/version/appendornot)](https://CRAN.R-project.org/package=appendornot)\n\u003c!-- badges: end --\u003e\n\nThe goal of `appendornot` is to provide easy access to writing and appending csv or text files.\n\n## Installation\n\nYou can install the development version of `appendornot` like so:\n\n``` r\n## install.packages(\"remotes\")\nremotes::install_github(\"favstats/appendornot\")\n```\n\n## Load Library\n\n\n```{r example}\nlibrary(appendornot)\n\n```\n\n## Motivation for `appendornot`\n\nI often find myself in the situation where I am scraping data and I want to keep appending some data to a file. However, I also want to make it so that it creates the file in the first place if it doesn't exist yet, then appends to it in the next iteration.\n\n## Example `save_csv()`\n\n\nWrite csv file with `save_csv`. The function will automatically create a new csv or append the file if it already does exist.\n\n\n``` r\nsave_csv(cars, \"cars.csv\")\n```\n\nYou can also create a folder (if it doesn't exist yet) before it saves the csv. Just specify: `create_subfolders = TRUE`.\n\nThis example creates the \"`data`\" folder first, then saves the file:\n\n``` r\nsave_csv(cars, \"data/cars.csv\", create_subfolders = TRUE)\n```\n\n### Different order and new variables to be appended (or are missing)\n\nNote: `save_csv` will automatically handle column order and column names that may not be present/are being added to the (appended) data.\n\n``` r\n## this data to be appended has a new column \nnew_column_dat \u003c- cars %\u003e% mutate(thisisnownew = \"hello\")\n\n## this is a different order than the original dataset\ndifferent_order \u003c- cars %\u003e% select(dist, speed)\n\n## this is a new column with a different order and missing a variable that is already there\ndifferent_order_newcolumn \u003c- new_column_dat %\u003e% select(dist, thisisnownew)\n\n```\n\nAll of these cases will be automatically handled by the `save_csv` function:\n\n``` r\nsave_csv(new_column_dat, \"cars.csv\")\n```\n\n``` r\nsave_csv(different_order, \"cars.csv\")\n```\n\n``` r\nsave_csv(different_order_newcolumn, \"cars.csv\")\n```\n\n## Example `save_lines()`\n\n\nWrite text file with `save_lines`. The function will automatically create a new text file or append the file if it already does exist.\n\n\n``` r\nsave_lines(names(cars), \"lines.txt\")\n```\n\nYou can also create a folder (if it doesn't exist yet) before it saves the text file.\n\nThis example creates the \"`txt`\" folder first, then saves the file:\n\n``` r\nsave_lines(names(cars),  \"txt/lines.txt\")\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fappendornot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffavstats%2Fappendornot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fappendornot/lists"}