Wednesday, October 23, 2013

An interesting LibreOffice Bug

Today I was changing a csv file into an SQL file. I normally do a lot of my work in Sublime Text, and make copious use of the ctrl+shift+L feature to bring up multiple cursors.
This was my general plan:

write the beginning insert sql statement insert into ... () values
then surround each row of the csv with ( and ) using sublimes multi-cursors. This worked after sublime grinded it's gears for 30 or so seconds (did I mention it's a rather large file I'm doing this to?) but then I realized I had forgotten to put in quotes around my text fields. If my data was nice, I would have simply used multiple cursors and ctrl+arrow keys to drop a quote in, skip over the word, then drop the next quote in and be done with it.

Unfortunately, there's more than one word in some of the text values and the number of words per row was different, so no such luck there.

I popped up vim real fast and figured maybe I could do a nice bit of vim-fu to throw down some quotes. After 10 minutes of googling (you can do vi( and vi) to jump around, but you can't do vi, to jump to a comma in visual mode.) I decided that I didn't know the right search terms to do it and so I opened up libre office figuring it might be able to help me out.

I selected all the cells in my column and went to format cells in the context menu, text type, and made a custom formatter for the cells that just threw quotes around the value. Great! Easy! But wait...

A bunch of values in one of my columns didn't bother to quote themselves. I stared at it for a bit, tried redoing the formatting, clearing it. After a bit I realized that the only difference between the cells that the format was applied to was the squiggly red line underneath each non-formatting cell.

The spell checker prevents a custom formater?

No way, I thought. But I told the spell checker to ignore one of the words, and lo and behold the cell was quoted suddenly.  So I shut off the spell checker entirely (it's in options, language, writing aids, and the check while you write option) and had a properly formatted column.

How insane! The Spelling error of a column should most definitely NOT prevent a format from being applied. I wonder if this is a known bug listed somewhere?