{ "info": { "author": "Martin Skarzynski", "author_email": "marskar@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# The `catren` python package\n\nUsing `catren` you can create and render [R markdown files](https://rmarkdown.rstudio.com/) in\n- your terminal or\n- your favorite Python environment (e.g. [PyCharm](https://www.jetbrains.com/pycharm/) or [Visual Studio Code](https://code.visualstudio.com/docs/python/python-tutorial)).\n\nThe `catren` python package consists of 4 functions:\n- `catrmd`, which con**cat**enates input files to output an [R Markdown](https://rmarkdown.rstudio.com/authoring_quick_tour.html) (Rmd) file.\n- `render`, which calls `rmarkdown::render` to create various output files (e.g. HTML documents).\n- `catren`, which combines the functionality of **cat**rmd and **ren**der.\n- `rmdtor`, which uses `knitr::purl` to convert an Rmd into an R script.\n\nAll of the above function work for Python _and_ R code, except `rmdtor` which skips Python chunks.\n\nTo run Rmd files that include R and Python code, you will need the `reticulate` R package.\n\nThe functions that begin with `r` (`render` and `rmdtor`) rely on the `rmarkdown` and `knitr`,\nR packages written by [Yihui Xie](https://yihui.name/en/about/).\nThe `catrmd` function has no dependencies beyond Python,\nall other functions (`render`, `catren`, and `rmdtor`) require R.\n\n## Installation\n\n```sh\npip install catren\n```\n\nor clone the [repo](https://github.com/marskar/catren), e.g. `git clone https://github.com/marskar/catren` and either use locally, e.g. `python catren.py header.yml README.md plot.py notes.txt` or install using setup.py, e.g. `python setup.py install`.\n\n## Basic usage: terminal\n\n### Creating an R markdown file with `catrmd` in the terminal\n\nThe `catrmd` functions works like `nbuild`. Provide all of the source files as arguments, e.g.\n\n```sh\ncatrmd header.yml intro.md letters.R notes.txt plot.py\n```\n\nThe default output filename for `catrmd` is `cat.Rmd`. By default, input and output files are located in the current directory (`'./'`).\n\nYou can provide a more descriptive filename for the unrendered Rmd (`-u`) and set different input (`-i`) and output (`-o`) filepaths:\n\n```sh\ncatrmd header.yml intro.md letters.R notes.txt plot.py --unrendered raw.Rmd --output_path rmarkdown/\n# Or\ncatrmd header.yml intro.md letters.R notes.txt plot.py -u raw.Rmd -o rmarkdown/\n```\n\nIf want to later output an R notebook using [RStudio](https://rmarkdown.rstudio.com/r_notebooks), your YAML header should include `html_notebook` as an output type (Hint: press ctrl/cmd+Shift+K).\n\n```yaml\n---\ntitle: \"Untitled\"\noutput: html_notebook\n---\n```\n\nThe `render` function from the `rmarkdown` R package allows you to specify the output type on the fly with the `output_format` argument.\n\n## Basic usage: python environment\n\n```python\n# You can import any or all of the functions from the catren package.\n\n# You can also import each function individually\nfrom catren import catrmd\nfrom catren import render\nfrom catren import catren\nfrom catren import rmdtor\n\n# The above imports all 4 functions\n# This can also be done with either of the two lines below.\nfrom catren import nbuild, nbexec, nbless, catrmd\nfrom catren import *\n\n# Another alternative is to import the package and use it as a namespace.\nimport catren as cr\n\n# Use individually\n\n# To make an Rmd file, use catrmd\ncatrmd([\"header.yml\", \"intro.md\", \"letters.R\", \"plot.py\", \"notes.txt\"], output_path=\"rmarkdown/\")\n\n# catrmd will also work with Python scripts.\ncatrmd([\"header.yml\", \"README.md\", \"plot.py\", \"notes.txt\"], output_path=\"notebooks/\")\n\n# Or to run both catrmd and render at once, use catren\ncatren[\"README.md\", \"plot.py\", \"notes.txt\"], nbexec_path=\"notebooks/\")\n\n\n# Use nbless as a namespace\ncr.catrmd([\"header.yml\", \"intro.md\", \"letters.R\", \"plot.py\", \"notes.txt\"], output_path=\"rmarkdown/\")\n```\n\nYou can also run the `catren` functions in an R environment using the `reticulate` R package.\n\n### Missing a dependency?\n\nIf you installed Python and R with [Anaconda](https://www.anaconda.com/download/), you should already have all of the dependencies (`python` and `r-essentials`).\n\nIf not, or if you have [Miniconda](https://conda.io/miniconda.html) installed, run\n\n```sh\nconda install -yc r r-essentials\n```\n\n## Too many file names to type out?\n\nYou can use the `ls` command to assign all of the relevant names in the current directory to a variable and pass this variable as an argument to `nbconvert.py`.\n\nTo preserve the order and differentiate files that should be incorporated into the notebook, I recommend left padding your file names with zeros (e.g. 01_intro.md, 02_figure1.py).\n\nConsider the example below:\n\n```sh\ntouch {01..09}.py\nname_list=`ls 0*.py`\npython catrmd.py `echo $name_list`\n```\n\nIn a python environment, I recommend `os.listdir` to obtain a list of all files:\n```python\nfrom os import listdir\nfrom os.path import isfile, join\nonlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/marskar/nbless", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "catren", "package_url": "https://pypi.org/project/catren/", "platform": "", "project_url": "https://pypi.org/project/catren/", "project_urls": { "Homepage": "https://github.com/marskar/nbless" }, "release_url": "https://pypi.org/project/catren/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Create R markdown files from markdown files and scripts.", "version": "0.0.1" }, "last_serial": 4323770, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "97b387bd6b9f2530774c43c0c70abd1f", "sha256": "4e3df8cac9f98fa5b26d57f2a2d69abc85692a0811ddb0d0c8fd01c6b5bf36f4" }, "downloads": -1, "filename": "catren-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "97b387bd6b9f2530774c43c0c70abd1f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3308, "upload_time": "2018-09-29T23:51:29", "url": "https://files.pythonhosted.org/packages/11/8d/97d2b7029076b542145c8fc19fc3e9a8811995ed8f3ed28ac24ae966555f/catren-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5657a5610b07e524b62aa97ec2343a28", "sha256": "1508071b87230e0534665b0f81dbe3d9f670f62fe58236dcbd5ac40a2048679a" }, "downloads": -1, "filename": "catren-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5657a5610b07e524b62aa97ec2343a28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3377, "upload_time": "2018-09-29T23:51:30", "url": "https://files.pythonhosted.org/packages/fe/37/eabe6fba7305f9e21cdbb2cacff771be4c730072fadb5d7b5bf64efeb04c/catren-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "97b387bd6b9f2530774c43c0c70abd1f", "sha256": "4e3df8cac9f98fa5b26d57f2a2d69abc85692a0811ddb0d0c8fd01c6b5bf36f4" }, "downloads": -1, "filename": "catren-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "97b387bd6b9f2530774c43c0c70abd1f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3308, "upload_time": "2018-09-29T23:51:29", "url": "https://files.pythonhosted.org/packages/11/8d/97d2b7029076b542145c8fc19fc3e9a8811995ed8f3ed28ac24ae966555f/catren-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5657a5610b07e524b62aa97ec2343a28", "sha256": "1508071b87230e0534665b0f81dbe3d9f670f62fe58236dcbd5ac40a2048679a" }, "downloads": -1, "filename": "catren-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5657a5610b07e524b62aa97ec2343a28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3377, "upload_time": "2018-09-29T23:51:30", "url": "https://files.pythonhosted.org/packages/fe/37/eabe6fba7305f9e21cdbb2cacff771be4c730072fadb5d7b5bf64efeb04c/catren-0.0.1.tar.gz" } ] }