From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Cave Subject: How I run org-agenda -csv to create data for my ListPro program Date: Sat, 29 Sep 2007 18:33:07 +1000 Message-ID: <46FE0DC3.4090206@optusnet.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IbXlR-00013l-QF for emacs-orgmode@gnu.org; Sat, 29 Sep 2007 04:33:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IbXlP-00011b-SK for emacs-orgmode@gnu.org; Sat, 29 Sep 2007 04:33:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IbXlP-00011F-MZ for emacs-orgmode@gnu.org; Sat, 29 Sep 2007 04:33:27 -0400 Received: from mail15.syd.optusnet.com.au ([211.29.132.196]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IbXlO-0005hB-Uc for emacs-orgmode@gnu.org; Sat, 29 Sep 2007 04:33:27 -0400 Received: from [192.168.1.100] (c220-239-237-243.thorn1.nsw.optusnet.com.au [220.239.237.243]) (authenticated sender charles_cave) by mail15.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id l8T8XI6q001507 for ; Sat, 29 Sep 2007 18:33:19 +1000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I wanted to show how I use the org-batch-agenda-csv command to create a file to import into the ListPro program that I run on my Palm M515 handheld. ListPro is from http://www.iliumsoft.com In my .emacs file I have this helper function: (defun org-csv-agenda () (org-batch-agenda-csv "H") ) The H refers to a prestored command: ("H" "Home NA Lists" ((agenda) (tags-todo "HOME") (tags-todo "COMPUTER") (tags-todo "OFFICE") (tags-todo "DVD") (tags-todo "READING"))))) I run a Perl script "agen2lpro.pl" that runs the helper function, captures the comma-separated output into a file, then processes this file to create a tab-delimited file for importing into ListPro. I manage my lists on the Palm and synchronise back to my Windows Machine. The ListPro list can be exported to a tab delimited and processed with another Perl script, but I don't attempt to do any updating of the original org-mode file marking completed items, but that is planned for the future. Here is the Perl script use strict; use warnings; my $emacs_exe = "\"D:\\Program Files\\emacs_22\\emacs-22.1\\bin\\emacs.exe\""; my $work_file = "agenwork.txt"; print "Create CSV file using Emacs\n"; my $cmd = system("$emacs_exe --batch -l c:/homes/charles/.emacs -f org-csv-agenda > $work_file"); print "$work_file (workfile) Created.\nProcessing ...\n"; # The output of this script is a tab delimited file to import # into ListPro. The fields are # # Description # Category (OFFICE, HOME, DVD, or READING) # Date - Either the scheduled date or blank. # DateLoaded - Todays date in month and day format in order to # identify Listpro items that originated from org-mode my $listpro = "listpro.txt"; open (my $fv, "<", $work_file) or die "Could not open $work_file: $!\n"; open (my $of, ">", $listpro) or die "Could not create $listpro: $!\n"; my @ltime = localtime(); my $datestring = sprintf("%d%d" , $ltime[4] + 1, $ltime[3] ); print "Version string $datestring\n"; my ($category, $headline, $type, $todo, $tags, $date, $time, $extra, $priority_l, $priority_n); while(<$fv>) { chomp; ($category, $headline, $type, $todo, $tags, $date, $time, $extra, $priority_l, $priority_n) = split(/,/); if ($tags =~ m/^([A-Za-z]+):/) { $tags = $1; } $tags = uc($tags); if ( ($type eq "scheduled") or ($type eq "typestamp") ) { my @d = split(/-/, $date); # orgmode used YYYY-M-DD format my $newdate = $d[2]."/".$d[1]."/".$d[0]; print $of "$headline\t$tags\t$newdate\t$datestring\n"; } if ( $type eq "tagsmatch" ) { print $of "$headline\t$tags\t\t$datestring\n"; } } print "Finished! Now load the file $listpro into Listpro\n";