{"id":16999519,"url":"https://github.com/rosalynlp/friendlyloader","last_synced_at":"2026-05-27T18:32:55.531Z","repository":{"id":42078940,"uuid":"473566218","full_name":"RosalynLP/friendlyloader","owner":"RosalynLP","description":"Helps with routine loading of Excel and csv files which have names subject to minor change.","archived":false,"fork":false,"pushed_at":"2024-07-03T07:59:09.000Z","size":66,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-08T05:59:51.938Z","etag":null,"topics":["csv","excel","file","loader","r"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RosalynLP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-03-24T10:55:10.000Z","updated_at":"2024-07-03T07:57:49.000Z","dependencies_parsed_at":"2022-08-12T04:20:15.524Z","dependency_job_id":null,"html_url":"https://github.com/RosalynLP/friendlyloader","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/RosalynLP/friendlyloader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosalynLP%2Ffriendlyloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosalynLP%2Ffriendlyloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosalynLP%2Ffriendlyloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosalynLP%2Ffriendlyloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RosalynLP","download_url":"https://codeload.github.com/RosalynLP/friendlyloader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RosalynLP%2Ffriendlyloader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33579665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["csv","excel","file","loader","r"],"created_at":"2024-10-14T04:09:04.909Z","updated_at":"2026-05-27T18:32:55.513Z","avatar_url":"https://github.com/RosalynLP.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"friendlyloader\n========\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/RosalynLP/friendlyloader)](https://github.com/RosalynLP/friendlyloader/releases/latest) ![Branches](https://badgen.net/github/branches/RosalynLP/friendlyloader/) ![Stars](https://badgen.net/github/stars/RosalynLP/friendlyloader)\n\nThe goal of `friendlyloader` is to help with routine running of scripts \nwhere you expect to find a file in a certain location, but where the\nname of the file can be subject to minor changes, such as a change in \ndate or using \"_\" or \"-\" instead of spaces.\n\n## Installation\n\nYou can install the development version of friendlyloader like so:\n\n``` r\nremotes::install_github(\"RosalynLP/friendlyloader\")\n```\n\n## How to use\n\nThis package includes wrapper functions for `utils::readcsv`, `readxl::read_excel` and `openxlsx::read.xlsx`. Namely:\n\n1. `friendlyloader::read_csv_with_options`\n2. `friendlyloader::read_excel_with_options`\n3. `friendlyloader::read_xlsx_with_options`\n\nYou supply the usual arguments to these functions, with the optional additional choices:\n\n* `useRstudio` (default `TRUE`). A boolean indicating whether to pick an alternative file using interactive R Studio windows, or (when set to `FALSE`) whether to use the terminal.\n\n* `recursive` (default `TRUE`). A boolean. Only impactful when `useRstudio == FALSE`. Whether to look for files recursively or only in the chosen directory.\n\n### Creating a friendly loader for a different file type\n\nIf you want to load a file other than csv or Excel you can easily create your own loader \nusing `create_loader_with_options()`. This takes in a function for loading your desired filetype\nand outputs a friendly version of that function. For example, for loading RDS files using `readRDS()`:\n\n```r\nread_rds_with_options \u003c- create_loader_with_options(readRDS)\n\nread_rds_with_options(\"some_arbitrary_file.rds\")\n\n```\n\n### Matching filenames with dates stripped out\n\nSometimes you want to load a file in a given location but the date of the file is subject to change. `match_base_filename` allows you to load the  file without triggering an interactive set of options, which can be useful if you are running a server job or Rmarkdown:\n\n```r\n# This will read fruits_colours.xlsx \nopenxlsx::read.xlsx(match_base_filename(\"20220328_fruits_colours.xlsx\"))\n```\n\nNote that there can be only one file called \\*fruits\\*colours\\*xlsx in the given directory or else the call to this function is ambiguous and it will fail.\n\n### Creating input/output functions that write/read from a designated folder\n\nSometimes it is useful to keep a data folder separate from your working directory,\nbut in this case reading and writing to this folder can be cumbersome. \n\nYou can use the `create_location_io()` function to create a version of a given \ninput/output function which is linked to a given location that is not your \nworking directory. For example\n\n```r\n# Create tmp directory\nsystem(\"mkdir tmp\")\n# Make function\ncreate_location_io(readr::read_csv, \"tmp\", prefix=\"custom\")\n```\n\nThis generates a function called `custom_read_csv()` which acts just like \n`readr::read_csv()` but reads from the `tmp` directory instead of the working\ndirectory. \n\nThe name of the generated function is composed of the `prefix` plus `_` plus the\nname of the function to be wrapped, not including the package - i.e. just\n`read_csv` rather than `readr::read_csv`.\n\nIf the function you are wrapping contains \"read\", \"write\" or \"save\" in the name,\nyou don't have to specify whether it's an input or an output function. If not,\nyou can specify using the `io` argument.\n\n### Using the terminal selector - when `useRstudio = FALSE`\n\n#### Loading a csv \n\nThis is based on the function `utils::read.csv`\n\n``` r\nlibrary(friendlyloader)\n\n# Creating test data frame and writing to csv\ndf \u003c- data.frame (Fruit = c(\"Apple\", \"Orange\", \"Pear\"), Colour = c(\"Red\", \"Orange\", \"Green\"))\nwrite.csv(df, \"fruits_colours.csv\", row.names = FALSE)\n\n# Trying to load csv but with slightly wrong filename\nread_csv_with_options(\"20220328_fruits_colours.csv\", useRstudio = FALSE)\n\n#\u003eCould not find file 20220328_fruits_colours.csv. Searching for possible alternatives.\n#\u003eShould I use one of the files below?\n#\u003e# A tibble: 1 × 2\n#\u003e  Filename           Subdirectory\n#\u003e  \u003cchr\u003e              \u003cchr\u003e       \n#\u003e1 fruits_colours.csv .           \n#\u003eType the number to use, or type 'No' and press Enter.     1\n#\u003e   Fruit Colour\n#\u003e1  Apple    Red\n#\u003e2 Orange Orange\n#\u003e3   Pear  Green\n#\u003e\n```\n\n#### Loading the first sheet of an Excel file\n\nThere are two options which work in the same way. One is based on the function `readxl::read_excel`, and \nthe other is based on `openxlsx::read.xlsx`. The names of these functions are `read_excel_with_options` and `read_xlsx_with_options`, respectively.\n\n``` r\nlibrary(friendlyloader)\n\n# Creating test data frame and writing to csv\ndf \u003c- data.frame (Fruit = c(\"Apple\", \"Orange\", \"Pear\"), Colour = c(\"Red\", \"Orange\", \"Green\"))\nwritexl::write_xlsx(df, \"fruits_colours.xlsx\")\n\n# Trying to load csv but with slightly wrong filename\nread_excel_with_options(\"fruits-colours.xlsx\", useRstudio = FALSE)\n\n#\u003eCould not find file fruits-colours.csv. Searching for possible alternatives.\n#\u003eShould I use one of the files below?\n#\u003e# A tibble: 2 × 2\n#\u003e  Filename            Subdirectory\n#\u003e  \u003cchr\u003e               \u003cchr\u003e       \n#\u003e1 fruits_colours.csv  .           \n#\u003e2 fruits_colours.xlsx .           \n#\u003eType the number to use, or type 'No' and press Enter.     2\n#\u003e# A tibble: 3 × 2                                                                                                \n#\u003e  Fruit  Colour\n#\u003e  \u003cchr\u003e  \u003cchr\u003e \n#\u003e1 Apple  Red   \n#\u003e2 Orange Orange\n#\u003e3 Pear   Green \n#\u003e\n```\n\n#### Loading all sheets of an Excel file\n\nSame as above but use `read_all_excel_sheets()` rather than `read_excel_with_options()`.\nThis uses the `openxlsx` package to read the information.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosalynlp%2Ffriendlyloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frosalynlp%2Ffriendlyloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosalynlp%2Ffriendlyloader/lists"}