<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/effortlessly-read-rectangular-data-r-package-readit-1-0-0-released-on-cran/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://anotherblogaboutr.blogspot.com/2018/03/effortlessly-read-rectangular-data-r.html"> Another Blog About R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><span color>Another R package designed out of frustration, `readit` is now available. What follows is </span><a rel="nofollow" href="https://github.com/ryapric/readit" target="_blank">the README that you can find on Github</a><span color>, and verison 1.0.0 of </span><a rel="nofollow" href="https://cran.r-project.org/package=readit" target="_blank">readit is now available on CRAN</a><span color>. Please feel free to submit requests, </span><a rel="nofollow" href="https://github.com/ryapric/readit/issues" target="_blank">bug reports</a><span color>, etc.!</span><br><span color><br></span><span color><br></span><span color><br></span></p>
<div color><code>readit()</code> may be the only data-read function you ever need; by wrapping other popular reader packages, like <a rel="nofollow" href="https://cran.r-project.org/package=readr" target="_blank">readr</a>, <a rel="nofollow" href="https://cran.r-project.org/package=readxl" target="_blank">readxl</a>, <a rel="nofollow" href="https://cran.r-project.org/package=haven" target="_blank">haven</a>, <a rel="nofollow" href="https://cran.r-project.org/package=jsonlite" target="_blank">jsonlite</a>, <code>readit</code> provides one self-titled function to read almost anything that isn’t formatted like hot garbage. If you have faith that the underlying data is of modest quality, and don’t care how it’s delimited, or what its file extension suggests, then <code>readit</code> is for you.</div>
<div color>This package was inspired by a handover at work; I took over as Maintainer for a package that dealt with a lot of disparate file extensions, and quickly became frustrated with trying to keep track of which filename was delimited in what way. “Why can’t I just… ***f@!#ing read it?!***” And lo, <code>readit</code> was born!</div>
<hr color>
<h3 color><a rel="nofollow" href="https://github.com/ryapric/readit#features" target="_blank"></a>Features</h3>
<div color><code>readit</code> is a pretty straightforward R package. It only exports one function, <code>readit()</code>, which wraps most of the reader functions in <a rel="nofollow" href="https://cran.r-project.org/package=readr" target="_blank">readr</a>, <a rel="nofollow" href="https://cran.r-project.org/package=readxl" target="_blank">readxl</a> <a rel="nofollow" href="https://cran.r-project.org/package=haven" target="_blank">haven</a>, and <a rel="nofollow" href="https://cran.r-project.org/package=jsonlite" target="_blank">jsonlite</a>. You can pass any arguments that you would normally pass to those functions, to <code>readit()</code>, as well.</div>
<div color><code>readit()</code> uses some basic heuristics based on the file extension to call the appropriate read function, and if it’s too ambigious (like <code>.txt</code> files), <code>readit()</code> will perform some commonly-implemented checks to guess the correct delimiter. <code>readit()</code> will always print out what file type it guessed (in nice, bold, green console text, via crayon, as a sanity check, and throw an error if the file path you give it is parsed and determined to be too messy to deal with automatically. For example, say you have some <code>.txt</code> file that you receive from a client each month, and it’s delimited differently every time (because that’s how it goes). Instead of inspecting it with four or five <em>different</em> functions first, you can just call <code>readit()</code> on it to pass it to <code>readr</code>‘s… readers:</div>
<pre><code>> readit(&quot;path/to/frustrating/file.txt&quot;)<br>File guessed to be pipe-delimited (&quot;path/to/frustrating/file.txt&quot;)<br>Parsed with column specification:<br>cols(<br>  testheader1 = col_character(),<br>  testheader2 = col_character(),<br>  testheader3 = col_character(),<br>  testheader4 = col_character(),<br>  testheader5 = col_character(),<br>  testheader6 = col_character()<br>)<br># A tibble: 5 x 5<br>  testheader1 testheader2 testheader3 testheader4 testheader5<br>  </code></pre>