SQLite User Forum

.mode column
Login

.mode column

(1) By anonymous on 2022-03-17 09:43:05 [link] [source]

Is there a way to suppress the underlining of column names when using .mode column? That is, have the column names followed by the column data?

(2) By Larry Brasfield (larrybr) on 2022-03-17 14:59:26 in reply to 1 [link] [source]

There is no such option now.

Is your inquiry due to an aesthetic result you are after? Or do you have some unusual downstream processing consumer in mind?

You could immediately precede your query with this: .mode column .once "|awk 'FNR!=2 {print}'" , achieving the effect you want for one query.

(5) By anonymous on 2022-03-17 17:33:24 in reply to 2 [source]

There is no such option now.

Was it possible in an earlier version then? (I've started with SQLite V3.33).

Is your inquiry due to an aesthetic result you are after?

Everything except the underlining comes from the database; the underlining is quite handy for tabular reports. However, if I want to paste it into, say, Excel, I need to remove the underlining in order to filter the data. Also, if I want to construct a data frame, I need to remove the underlining.

Removing the underlining becomes a tedious and repetitive task which I wanted to avoid; hence the original question.

My OS is Windows; your suggestion gives me an error:

sqlite> .once "|awk 'FNR!=2 {print}'"
sqlite> 'awk' is not recognized as an internal or external command,
operable program or batch file.

Is there an equivalent for Windows?

(6) By Keith Medcalf (kmedcalf) on 2022-03-17 17:39:30 in reply to 5 [link] [source]

Yes. THe GNU and/or Unix utilities have been compiled natively to run on DOS/Windows/NT since those platforms came into existance.

http://gnuwin32.sourceforge.net/packages/gawk.htm

is but one.

(7) By Larry Brasfield (larrybr) on 2022-03-17 17:58:43 in reply to 5 [link] [source]

There is no such option now.

Was it possible in an earlier version then?

There has not been any such feature, now or in the past. I decline to soothsay.

However, if I want to paste it into, say, Excel, I need to ...

For that, you are better off using ".mode tabs" and collecting the output into a file to read into Excel. Or just use the ".excel" command. With that, you may need to copy (or cut) and paste ranges afterward, but you would avoid a mess of issues which arise with screen scraping. Alternatively, I have found that using a clipboard command-line utility to accept the output of ".mode tabs" query results works well. For example: .mode tabs .header on .once |clip SELECT ... , followed by pasting into a worksheet, will work on recent versions of Windows because they have a program called clip.exe which you might want to add to your toolbox.

My OS is Windows; your suggestion gives me an error: ...
Is there an equivalent for Windows?

GAWK for Windows is an excellent equivalent (or better.)

(3) By Keith Medcalf (kmedcalf) on 2022-03-17 15:59:53 in reply to 1 [link] [source]

.mode line

(4.1) Originally by anonymous with edits by Stephan Beal (stephan) on 2022-03-17 18:04:20 from 4.0 in reply to 3 [link] [source]

This does not give me what I seek, namely the output achieved by .mode column but without the underlining of the column headers (names).

EmployeeId = 7
  LastName = King
 FirstName = Robert
     Title = IT Staff
 ReportsTo = 6
 BirthDate = 1970-05-29 00:00:00
  HireDate = 2004-01-02 00:00:00
   Address = 590 Columbia Boulevard West
      City = Lethbridge
     State = AB
   Country = Canada
PostalCode = T1K 5N8
     Phone = xxxxxxx
       Fax = xxxxxxx
     Email = xxxxxxx

[[Edited by Stephan to remove someone's private contact info. @OP: please be careful what you paste into the forum, as search bots can pick it up.]]

(8) By anonymous on 2022-03-17 18:46:30 in reply to 4.1 [link] [source]

Thanks for editing; I'll remember to heed your advice in future.

(9) By SeverKetor on 2022-03-17 20:55:35 in reply to 8 [link] [source]

To be fair, if that's actually someone's real info, they were hosed long before that post. A quick Google shows an example SQL query with all that info anyway.

(10) By Donald Griggs (dfgriggs) on 2022-03-18 17:52:41 in reply to 4.1 [link] [source]

Regarding "This does not give me what I seek..."

Maybe you were responding to another post, but just to be sure -- Larry Brasfield's post of 2022-03-17 17:58 provides precisely what you asked for, is that not correct?

(11) By anonymous on 2022-03-18 18:59:51 in reply to 10 [link] [source]

I got an error as I reported because I did not yet have awk at the time ... looking to install this.

(12) By Larry Brasfield (larrybr) on 2022-03-18 19:55:24 in reply to 11 [link] [source]

Mr. Griggs was referring to my post #7 wherein I laid out a couple more adequate solutions to your problem, including one I have often used myself for the very same problem.

(13) By anonymous on 2022-03-18 20:41:57 in reply to 12 [link] [source]

Larry, as you suggested:

  .mode tabs
  .header on
  .once |clip
worked fine (better, in fact, as there is only one tab separating columns)

However, I wanted the results in a file (rather than the clipboard) so I used

.output e:/temp/myresults.txt

instead of

.once | clip
and had to reset output
.output
for subsequent queries.

Thanks.