Reputation: 16081
To filter a table with org-mode in emacs I am using org-babel. However, my function does not quite work and I am not sure why. The following is the link to the zip file which contains the csv I am testing my function on: source. The csv is named 2014-1 SubdivisionCodes.csv.
First I open the file with emacs and then highlight the entire region and run the command org-table-create-or-convert
which transforms the CSV into an ORG table. Next I name the table using org-babel
syntax: #+tblname: un-states
Immediately following is the entire table. I want to filter out the rows that are states. Here is my code for filtering the table by the value in the fourth column:
#+name: filter-un
#+begin_src emacs-lisp :var tbl=un-states
(remove-if (lambda (row) (not (equal (cadddr row) "State"))) tbl)
#+end_src
I evaluate the function with C-c C-c
and the results I get are:
#+results: filter-un
| AU | NSW | New South Wales | State |
| AU | QLD | Queensland | State |
| AU | SA | South Australia | State |
| AU | TAS | Tasmania | State |
| AU | VIC | Victoria | State |
| AU | WA | Western Australia | State |
The data includes states in the United States of America, so we are clearly missing a lot of states. Why isn't my function working? What I immediately notice is that AU
is the first set of rows for which there are states and they are all contiguous rows. So it appears that it stops working after this point.
Thanks for all the help. I just started using org-babel
a few hours ago and all help is greatly appreciated!
Upvotes: 2
Views: 1144