Booom...........

LabNotes and Random Thoughts...............

Thursday, August 13, 2015

csvkit is kool


got some Sci-Fi audio books
I am listing out the book names, author and year into a neat table using csvkit

ls Top\ 100\ Sci-Fi\ Books\ -\ * | grep "^[0-9]"|  sed s'/-/\t/g' |csvsort -c 1| csvformat | csvlook -H | sed -e "s/column2/book   /; s/column3/author / ; s/column4/year   /; s/column1/sl_no  /"
|----------+-------------------------------------+----------------------+----------|
|  sl_no   | book                                | author               | year     |
|----------+-------------------------------------+----------------------+----------|
|  1       | Ender's Game                        | Orson Scott Card     | 1985     |
|  2       | Dune                                | Frank Herbert        | 1965     |
|  3       | Foundation                          | Isaac Asimov         | 1951     |
|  4       | Hitchhiker's Guide to the Galaxy    | Douglas Adams        | 1979     |
|  5       | 1984                                | George Orwell        | 1949     |
|  6       | Stranger in a Strange Land          | Robert A Heinlein    | 1961     |
|  7       | Fahrenheit 451                      | Ray Bradbury         | 1954     |
|  8       | 2001; A Space Odyssey               | Arthur C Clarke      | 1968     |
|  9       | Starship Troopers                   | Robert A Heinlein    | 1959     |
|  10      | I, Robot                            | Isaac Asimov         | 1950     |
|  11      | Neuromancer                         | William Gibson       | 1984     |
|  12      | Do Androids Dream of Electric Sheep | Philip K Dick        | 1968     |
|  13      | Ringworld                           | Larry Niven          | 1970     |
|  14      | Rendezvous With Rama                | Arthur C Clarke      | 1973     |
|  15      | Hyperion                            | Dan Simmons          | 1989     |
|  16      | Brave New World                     | Aldous Huxley        | 1932     |
|  17      | The Time Machine                    | H G Wells            | 1895     |
|  18      | Childhood's End                     | Arthur C Clarke      | 1954     |
|  19      | The Moon is a Harsh Mistress        | Robert A Heinlein    | 1966     |
|  20      | The War of the Worlds               | H G Wells            | 1898     |
|  21      | The Forever War                     | Joe Haldeman         | 1974     |
|  22      | The Martian Chronicles              | Ray Bradbury         | 1950     |
|  23      | Slaughterhouse Five                 | Kurt Vonnegut        | 1969     |
|  24      | Snow Crash                          | Neal Stephenson      | 1992     |
|  25      | The Mote in God's Eye               | Niven & Pournelle    | 1975     |
|  26      | The Left Hand of Darkness           | Ursula K Le Guin     | 1969     |
|  27      | Speaker for the Dead                | Orson Scott Card     | 1986     |
|  28      | Jurassic Park                       | Michael Crichton     | 1990     |
|  29      | The Man in the High Castle          | Philip K Dick        | 1962     |
|  30      | The Caves of Steel                  | Isaac Asimov         | 1954     |
|  31      | The Stars My Destination            | Alfred Bester        | 1956     |
|  32      | Gateway                             | Frederik Pohl        | 1977     |
|  33      | Lord of Light                       | Roger Zelazny        | 1967     |
|  34      | Solaris                             | Lem Stanislaw        | 1961     |
|  35      | 20,000 Leagues Under the Sea        | Jules Verne          | 1870     |
|  36      | A Wrinkle in Time                   | Madelein L'Engle     | 1962     |
|  37      | Cat's Cradle                        | Kurt Vonnegut        | 1963     |
|  38      | Contact                             | Carl Sagan           | 1985     |
|  39      | The Andromeda Strain                | Michael Crichton     | 1969     |
|  40      | The Gods Themselves                 | Isaac Asimov         | 1972     |
|  41      | A Fire Upon the Deep                | Vernor Vinge         | 1991     |
|  42      | Cryptonomicon                       | Neal Stephenson      | 1999     |
|  43      | The Day of the Triffids             | John Wyndham         | 1951     |
|  44      | UBIK                                | Philip K Dick        | 1969     |
|  45      | Time Enough For Love                | Robert A Heinlein    | 1973     |
|  46      | A Clockwork Orange                  | Anthony Burgess      | 1962     |
|  47      | Red Mars                            | Kim Stanley Robinson | 1992     |
|  48      | Flowers for Algernon                | Daniel Keyes         |          |
|  49      | A Canticle for Leibowitz            | Walter M Miller      | 1959     |
|  50      | The End of Eternity                 | Isaac Asimov         | 1955     |
|----------+-------------------------------------+----------------------+----------|


ls Richard\ Dawkins/ | sed s'/-/\t/g' |csvsort -r -c 2,1 |csvformat | csvlook -H -l 

|--------------+----------------------------+----------|
|  line_number | column1                    | column2  |
|--------------+----------------------------+----------|
|  1           | An Appetite for Wonder     | 2013     |
|  2           | The Magic of Reality       | 2011     |
|  3           | The Greatest Show on Earth | 2009     |
|  4           | The God Delusion           | 2006     |
|  5           | The Ancestor's Tale        | 2004     |
|  6           | The Blind Watchmaker       | 1986     |
|  7           | The Selfish Gene           | 1976     |
|--------------+----------------------------+----------|


I gotta try out csvjson and csvsql.


No comments: