Tag Archives: csv

x_x: The Dead Guy CLI

With barely a week left for this site, I’m beginning to trim away programs that I just probably won’t get to, by virtue of time or technical dilemmas. I’m also making a conscious effort to pick out titles that amuse me in one form or another, so I finish with happy memories. πŸ˜›

x_x, which I mentally refer to as “the Dead Guy CLI,” because the home page uses that as a subtitle, is a rather nifty tool that I’m surprised I haven’t seen covered elsewhere. Using a bland, dull, boring Excel spreadsheet borrowed from a corner of the Interweb, Dead Guy CLI transmogrifies it into this:

2015-04-21-6m47421-x_x

Well isn’t that clever.

Dead Guy CLI gives you a small measure of control over your output, by allowing you to specify a header row or allow for special encoding. It also works with CSV files, so you’re not strapped trying to convert back and forth to Excel, just to fiddle with x_x.

Aside from that though, Dead Guy CLI seems very simple. Of course, your spreadsheet may need some management if you expect it to fit into a certain dimension, but I am confident that as a skilled and capable member of the information age, you won’t throw a wobbly over a pear-shaped spreadsheet.

Keep x_x in mind when you’re thinking about things like csv2xls or xlhtml, since it may save you a step or prevent you from relying on graphical tools just to extract data from a spreadsheet. And of course, if you’re working with csv files, x_x could supplement what tabview or other tools can do.

For my own recordkeeping, Dead Guy CLI gets points for doing something obvious that I don’t recall seeing elsewhere. And also for the snarky name. I’m a fan of snarky names. 😈

mange: The program with a delicate name

Every time I find a csv tool of some sort, I end up wishing I had more chances to work with csv files. The first program for today is a great example, even if I have to be careful how I phrase these next few sentences. This is mange:

2014-09-21-6m47421-mange-01 2014-09-21-6m47421-mange-02 2014-09-21-6m47421-mange-03

Before I am hounded by rabid animal rights activists, just let me say I didn’t pick the name. I can’t find any sort of explanation as to why “mange” is the title, unless there are non-English and non-other-languages-I-speak references. If you know, let me in on the secret.

And I’d like to know, because mange is a pretty good program. I don’t come across many csv editors — viewers, yes, and utilities, yes. Even spreadsheets for the console. But now that I think of it, not many editors. Finding mange is a lucky event.

mange works in a straightforward fashion — arrow keys to navigate cells, enter to edit them. mange will stick to an editor mode and fall cell by cell as you edit, which makes data entry much easier.

mange also has the sense enough to display and keep a header row, as you can see in the images above. And it seems to handle terminal width and four-way scrolling without too much effort.

I did see a couple of screen corruption problems, usually when editing a long field on a wide spreadsheet that was pressed up against the rightmost edge. I have a feeling there might be a small tweak to get the screen to refresh properly after editing a cell that stretches over the screen width.

mange has a couple of features I didn’t get to, just because they’re tied to the statistical package r, and the time it would take me to learn to work them together would delay this post until about Thursday. So take it on faith that mange can feed data into r, and generate plots and graphs.

Your best bet for getting started with mange is the man page, where most of the controls and the editing-command-navigation modes are explained. It won’t take long.

I’m sad to see that the last update to mange was around three years ago, which makes me wonder if the list of coming attractions in the README file is ever going to materialize. I guess that remains to be seen. :\

csv2xls: Back to the harmless and mundane

After yesterday’s foray into the dark and sinister worlds of password cracking and torrent searching πŸ™„ , today we’ll play the innocent and take a glance at csv2xls.

2014-08-09-6m47421-csv2xls-01 2014-08-09-l3-b7175-csv2xls-02

What could be more upright and resepectable than converting a plain old csv-formatted address list into an Excel spreadsheet? And I mean that with all seriousness. 😐

As you can see above, csv2xls did a precise job of converting my database into a spreadsheet, accessible by LibreOffice and likely Excel too … but I don’t own a copy of that, so I can’t be 100 percent sure. πŸ˜‰

I’m tempted to stop there and say, “Yup, it works. Let’s move on.” But I see a couple of options in the man page that might be worth pursuing.

For one thing, my spreadsheet was only 100 names long. That’s no monster, and I doubt that csv2xls worked very hard to convert it. By default csv2xls will dump one csv file into one xls file, but the -l option will break it off after a certain number of lines. Successive entries are put into numbered files, ad infinitum, ad astra.

I can see the usefulness in that, but I can’t actually see a case where I personally would need it. Unless I churn out a 1000-line csv file and break it apart by hundreds, just to amuse you. O_o

One other curious and related note: If your csv file has a header line, csv2xls will keep that header across line-split files if you use the -H flag. So you needn’t worry that your grade sheet or customer invoice will lose its header row across files.

And I suppose I should mention that the default delimiter for csv2xls is … a semicolon. πŸ˜• Remember to use the -d flag if your comma-separated values are actually (gasp!) separated with commas. πŸ™„

I’ll leave it at that. csv2xls does a good job, I encountered no errors, and it has enough options to make it useful beyond the obvious. If only it didn’t talk so much. … πŸ˜‰

P.S.: If you’re looking to go the opposite direction, check here or here. Hey, now you can convert your csv files to HTML. … 😯 😎

uncsv: So much easier than search-and-replace

Like I said some weeks ago, it’s rare that I have a chance to use comma-separated value data files. It’s just not something that I see on a day-to-day basis.

That might be part of the reason I find uncsv so interesting. For me, just the idea of having to wrangle with a csv file and convert it to something slightly different is frightening.

2014-06-10-6m47421-uncsv

And yet uncsv does it without the least bit of effort. You have the option to pick your delimiter, play footsie with carriage returns and line feeds, and send the data through to other tools.

uncsv has its polar opposite in csv, which (as you might imagine) converts delimited text files into properly structured csv format.

csv is almost worth mentioning in and of itself, since it offers an additional three or four options, such as bracketing everything in quotes — as you can see here.

2014-06-10-6m47421-csv

These are fun to play with, and if you need to work with csv files on a regular basis, this could be a better option than whatever method you’re used to.

As for me, I’m going to concoct a few more phony databases, just so I can watch it do its thing. πŸ™‚

tabview: csv files have never been cooler

Sometimes I find a utility so cool and obvious that I spend a few hours intentionally complicating life, just to watch it untangle things.

For example, I wrestled for about 10 minutes to come up with this …

2014-05-15-6m47421-tabview-01

just so I could watch tabview turn it into this:

2014-05-15-6m47421-tabview-02 2014-05-15-6m47421-tabview-03

(Thanks to rig for supplying the phony address book data.) tabview reads csv files (although as you can see, they don’t need a .csv extension) and drops them into a spreadsheet-ish arrangement for viewing purposes.

And that’s where it stops. No printing, no editing, no format conversion. Just view, simple sort by column, searching, primitive bookmarking, and maybe a highlighted header row.

That’s what I love about it most: tabview takes the tedious chore of skimming through csv files, then simplifies it, adds fundamental controls and options, and then knows enough not to pollute that genius with frills and foppery.

I won’t call it “perfect,” mostly because that word gets thrown around too much on this blog. It is possible to make it crash; I did it more than once trying to navigate and view cells on a super-large file.

And it also has a small flub in the aforementioned header row feature: The header data isn’t “pulled” from the data array, which means it appears twice in a row when you first open a file, and then gets mixed in with the other data if you sort the rows in any way.

And I don’t see where it’s possible to revert to the original data order, after you sort.

But to be honest, tabview is pretty much feature-complete for me. If it went any further in any direction, I’d lose interest. Do one thing. Do it well. Don’t drag my system down. Points are awarded for style.

Here’s a coveted K.Mandla gold star for tabview: ⭐ πŸ˜‰

csvkit: Lots of little tools, in a pack

I don’t work with csv files much, but I hear they are popular among those who use databases.

I have run through one or two, for example when converting from sc format to csv, for access through conventional graphical spreadsheets. That requires a little search-and-replace acrobatics, as you might expect. To that end, csvkit has some nifty tools in it.

2013-09-27-v5-122p-csvkit

csvclean can touch up small errors in a csv file. csvlook displays the contents in a table format, drawn with a header and ASCII lines.

csvstat can give you a breakdown of each column in a csv file, and there are csvcut, csvgrep, csvsort, csvjoin … among still others.

It seems that most of the tools have some unified flags and options; for example, the flag to declare a different delimiter in csvlook is the save in csvstat. Uniformity: That’s a good idea.

There are enough tools in here to keep the maddest scientist busy for a while, and I doubt it would take long to adopt them. If you work with csv files a lot, this might be the tool you’ve been waiting for. πŸ˜‰