Over Thanksgiving break we were treated to a panoply of cloud types from the mountaintop view of Queen Wilhelmina State Park Lodge. The graphic below was the best of a number of compelling illustrations that helped to sort out types of clouds seen:


Concatenate Text Files with File Names

Last night I needed to compile a folder (directory) of text files into a single file with the file name as a header. This simple bash script did the work:

% for f in *.txt; do echo "# $f"; cat "$f"; done > ../legends.txt

The hash sign ahead of the filename reveals that I compiled the document as a markdown text. I couldn’t quite figure out how to insert newlines into the script above, so I ended up using some regex to do that: finding instances of the hash tag and inserting a new line before it and then finding instances of .txt and inserting a newline after it. And then, finally, removing the .txt extension altogether. From there, I converted the document to HTML that I could format more clearly.

As seen here, I entered the script directly at the command line, but it could also, I suppose be saved thus:

#! /usr/bin/env bash

for f in *.txt; 
    do echo "# $f"; 
    cat "$f"; 

I’m not sure how to direct the output into a file within a bash script. I usually just do that at the command line. (I know, I know: I need to learn bash scripting. I’ll get there.)

More on Jupyter

While I was pretty happy to get both Python 3 and R working in Jupyter notebooks, I had no idea that you could use both in the same notebook. Check out this presentation by Myles Gartland where he explains the power of %R in Jupyter notebook: Youtube.

Trying Out Indico’s “plotlines”

Running parallel to Jockers’ attempts to “plot” texts via sentiment analysis, Indico Data Solutions has released a Python package plotlines as well as a Jupyter notebook of documentation and sample code.

Neither indico nor plotlines turned up in a port search so my next step was to try pip. My first attempt revealed that I was still using the Python 2.7 version of pip, and I needed both to get the version for Python 3.4 but also make sure it was the active version:

sudo port install py34-pip
sudo port select -- pip pip34

And, then, to the matter at hand:

sudo pip install -U indicoio


More Notes on Jupyter Notebook

I used MacPorts, as always, to install the new code for Jupyter:

port install py34-jupyter

Note: you may need to prepend sudo to install software on your setup.

But the new command jupyter notebook only returned -bash: jupyter: command not found for me. I tried various alternatives, but got nowhere until I returned to ipython notebook. Presto. And even better, now I have this:

Python or R?

Python or R?

Getting the R there is considerably simpler now, while in the R shell:

             repos = c('', 


See iRkernel for more information.