Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
Created November 22, 2015 14:34
Show Gist options
  • Save priyadarshan/e6ddc4820f9b7af63595 to your computer and use it in GitHub Desktop.
Save priyadarshan/e6ddc4820f9b7af63595 to your computer and use it in GitHub Desktop.
Read a file containing lines like foo=bar and output to a new file like this (foo . bar)
(defun arabic_to_roman (filename)
(cl-flet ((read-it ()
(with-open-file (in filename
:direction :input
:if-does-not-exist nil)
(loop for line = (read-line in nil)
for pos = (position \= line)
while line collect (cons (subseq line 0 pos)
(subseq line (1+ pos))))))
(write-it (list)
(with-open-file (cl-stream #p"ar_out.txt"
:direction :output
:if-exists :overwrite
:if-does-not-exist :create)
(write list :stream stream :escape nil :readably nil :pretty nil))))
(write-it (read-it))
'done-read-write))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment