Skip to content
/ csvorg Public

Export/import Emacs Org mode entries to/from csv-files

Notifications You must be signed in to change notification settings

orgtre/csvorg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

csvorg

This Emacs package lets you convert a set of org-mode entries to a csv-file and the other way around. It extends and complements similar functionality provided by a combination of the built-in org-collector and org-table, or the external package emacs-org-transform-tree-table. The pcsv package is used as csv-parser when importing and org-map-entries is used to collect entries when exporting.

Usage

Two commands are provided: csvorg-export and csvorg-import. They can be used interactively, but to access all options non-interactive use is required. Their docstring explains how to use them.

Example

(csvorg-export
 "csvorg-test-from-org.csv" nil
 '("ITEM" "prop1" "prop0" "TODO" "TAGS" "child1")
 "LEVEL=2" '("csvorg-test.org") t t)

for a file csvorg-test.org with content:

* entries
  :PROPERTIES:
  :prop0: value of prop0
  :END:

** head1
   :PROPERTIES:
   :prop1: value of head1prop1
   :END:

*​** child1

    content of head1child1


** DONE head2 :tag1:tag2:
   :PROPERTIES:
   :prop1: value of head2prop1, with comma
   :prop2: value of head2prop2
   :END:

*​** child1

    content of head2child1, with comma

    and linebreaks


*​** child2

    content of head2child2

will create the file csvorg-test-from-org.csv with content:

ITEM , prop1                            , prop0         , TODO, TAGS       , child1
head1, value of head1prop1              , value of prop0,     ,            , content of head1child1
head2, "value of head2prop1, with comma", value of prop0, DONE, :tag1:tag2:, "content of head2child1, with comma\n\nand linebreaks"

where the spaces between fields are only inserted here for display purposes.

(csvorg-import
 "csvorg-test-from-org.csv"
 "csvorg-test-from-org-and-back.org"
 nil '("prop1" "prop0" "TODO" "TAGS")
 '("child1") "entries")

now imports this csv-file into org by creating the file csvorg-test-from-org-and-back.org with contents:

* entries

** head1
   :PROPERTIES:
   :prop1: value of head1prop1
   :prop0: value of prop0
   :END:

*​** child1

    content of head1child1


** head2
   :PROPERTIES:
   :prop1: value of head2prop1, with comma
   :prop0: value of prop0
   :'TODO: DONE
   :'TAGS: :tag1:tag2:
   :END:

*​** child1

    content of head2child1, with comma

    and linebreaks

Note the following:

  • All Org entries user properties, special properties, and children (subheadings with contents) can be exported.
  • To determine entries for export, the flexible match and scope arguments of org-map-entries can be used.
  • On import the Org entry heading can be constructed using an arbitrary function of the corresponding csv row and the column names, with sensible defaults.
  • Hooks are provided for transforming column names on import, and field values on import and export, again with sensible defaults.
  • If all entries user properties and children are exported, no special properties are used except ITEM, property inheritance is disabled, entries contain no extra leading or trailing whitespace, and all exported entries are children of the same parent, then one gets back the same thing after an export and import.

About

Export/import Emacs Org mode entries to/from csv-files

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published