DONE lob function for reading files

  • State "DONE" from "TODO" 2010-06-06 Sun 19:53
  • State "TODO" from "" 2010-06-06 Sun 10:11

This runs up against an increasingly common theme of tension between implementing functionality in org-babel vs. in host languages.

Nearly every language which would be used inside of a code block has it's own mechanisms for reading the contents from a file, so to what extent do we want to implement this functionality inside of org-babel vs. leaving this up to the host language.

I think this may be a good place for a library of babel function.

Once we have an lob function, say read-file then we can place

:var path="<doi:10.1000/182>" or :var path="doi:10.1000/182]]"

in a header argument to pass a path to a code block, and we can place

:var path=read-file(path="<doi:10.1000/182>") or :var path=read-file(path="doi:10.1000/182]]")

in a header argument to pass the contents of a file to a code block.

Should the files be returned as a string, or as a list of lines? How about both.

read
reads the file and returns one large string
read-lines
reads the file and returns a list of lines

(see the library of babel in contrib/babel/library-of-babel.org)