17 July 2020

Mac .textClipping to .txt

by David Moss

Macintosh computers have a wonderful feature that allows you to highlight text in any window and drag it onto the desktop, or into a folder.

Not so wonderful is the fact no other program but Finder can use the files it creates. The suffix of these exotic files is .textClipping and the text is stored in the resource fork of the file, not the data fork of this peculiar Macintosh file format.

Dealing with just one of these files is hard enough, but I produced over a hundred of them by dragging text out of Facebook for sentiment analysis. I intended to import the text into NVivo. Dragging and dropping the .TextClipping files into NVivo did not work. NVivo simply couldn’t understand them. Nothing but Finder can understand them.

Browsing the web revealed this is a common problem and no-one has a drag and drop solution to it. So should I painstakingly redo my data capture, creating an individual file for each clipping, drag, drop and save each? Why would I spend tens of minutes doing that when I could spend hours creating a drag and drop solution?

I decided to use Apple Automater. Immediately I hit the first roadblock. Out of the box Automator has no way of ingesting a large number of files and dealing with them one by one. Fortunately Nyhthawk Productions created an ad-on for Automater called “Dispense Items Incrementally” that solves this problem. You can download it here.

With the add-on installed I wrote an Automator app that allows the user to drop a file, or set of .textClipping files onto it, extracts the text from the resource fork and saves each as a .txt file in a target folder.

I added a 1 second pause between the rename and the loop because Automater only allows the number of seconds since midnight as a filename in the rename block.

Note also the DeRez utility included with macOS Catalina is deprecated and could be removed in future OS upgrades.

Once the .textClipping files had been converted the resulting .txt files can be dragged and dropped into NVivo to be imported normally.

The Automator tool I created can be downloaded below:

23 June 2020

Wolfram Select Statement

I have been using Wolfram Mathematica to visualise some data around COVID-19. Selecting a subset of rows from a DataSet proved frustrating until I realised the field I was trying to select did not contain a string.

The Wolfram Notebook I was using can be found at https://www.wolframcloud.com/obj/admoss0/Published/Covid.nb

Wolfram language has some very powerful constructs. The following statement grabs a csv file from the Internet, works out what all the datatypes should be and stores it in a DataSet object named wdata.

wdata = SemanticImport [
data/owid-covid-data.csv “]

All good so far. The wdata object contains a huge amount of data. It has 25497 rows and 34 columns. I only wanted the new_cases column for a single country. Sounds easy. Until you try. After browsing the web about it I tried:

AUcases = wdata[Select[#location == “Australia”&], {“date”,”new_cases”}];

But that would have been too easy. It didn’t work. Yet example after example on the web indicated it should. The problem? It turns out the contents of the location field was not a string. It was an object.

screen capture of the line from Wolfram Desktop

It took 4 days and much of 4 nights to discover this. If you look closely the word Australia is inside a little orange box. It isn’t text. It isn’t a string. It is a Wolfram language COUNTRY object.

SemanticImport is too smart. It recognised the entries in the location field referred to countries and rather than just storing the name as a string, it stored a country object in the DataSet.

This is immensely useful for further processing. That country object contains all sorts of useful information, like population, GDP, you name it.

But until this one fact is known, that the location field does not contain strings, trying to select using a string for the country is maddening.

The Solution

Rather than surrounding the word Australia with “quotes” you press <CTRL>= and the Wolfram Desktop pops up a box for natural language input. Type Australia into that box and Wolfram checks Wolfram Alpha to see what it knows about it. It correctly works out Australia is a country and provides a country object. This matches the country object in the location field of the DataSet and magically the Select statement works!

Category: Tech | LEAVE A COMMENT
5 January 2020

My Tech


  • Macbook Pro (13-inch, 2020, Four Thunderbolt 3 ports)
  • iPad Pro
  • iPhone
  • Raspberry Pi 4
  • Arduino



  • Amazon Lightsail
  • Microsoft 365
  • Google Documents
  • Twilio
  • IBM Cloud
  • Dropbox
  • iCloud
  • Apple Developer

Time Machine

Who has ever deleted part of a document that later turned out to be important? Or attempted a system change that made the device un-bootable? Only me? OK, but the Apple Time Capsule has saved me more than a few times. This unobtrusive device sits forgotten next to my Internet Router.

Whenever my Mac comes within range, Time Machine backups are made automatically. These are continuous incremental backups so I can go back in time a few minutes, a few hours or a few months or years and restore previous versions of any file. Or an entire device. It just works.

Amazon Lightsail

Having a server on the Internet is essential for an IT professional.
Searching the market I found Amazon Lightsail to be the best value for the small scale test server I needed. This page is being served from a WordPress instance on a virtual server. I have root access to this virtual server and Amazon takes care of the network, hardware and operating system patching for me. For plain old HTML pages I simply create a sub directory below the WordPress directory and add HTML files. The Apache server that drives WordPress handles these pages just as a standalone Apache server would. I installed the Apache Jena Framework on Lightsail by following the standard installation instructions. This allows me to store data in a TDB triple store and query it using Fuseki. Literally anything I want to test or serve can be accomplished on Lightsail for $4.50 per month. If by some miracle I need to upscale I can buy incremental services and serve up to petabytes per second.

Category: Tech | LEAVE A COMMENT
31 December 2019

Site Development

This is a WordPress site running on a Lightsail instance hosted by Amazon.

The original version of this website was taken over by scammers in late 2019 and so badly damaged it had to be burned with fire.

I rebuilt the site with a closer eye to security and disaster recovery. It now uses Askimet anti-spam, Jetpack security and Vaultpress for off-site backup. I also gave the theme author due credit and bought Authors Notepad, the premium version of his work.  I hope you enjoy the result.

Category: Site, Tech | LEAVE A COMMENT