Created
July 30, 2012 06:58
-
-
Save unionx/3205410 to your computer and use it in GitHub Desktop.
read and split file in emacs lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/emacs --script | |
(defun read-lines (filename) | |
(with-temp-buffer | |
(insert-file-contents filename) | |
(split-string (buffer-string) "\n" t))) | |
;; test.log | |
;; 111111,22222222222,3333333333333 | |
;; 2222222222,3333333333,444444444 | |
;; 555555555,222222222,1111111 | |
;; 555555555,2222222,111111111 | |
(dolist (var (read-lines "test.log")) | |
(print (split-string var "," t))) | |
;; ("111111" "22222222222" "3333333333333") | |
;; ("2222222222" "3333333333" "444444444") | |
;; ("555555555" "222222222" "1111111") | |
;; ("555555555" "2222222" "111111111") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it rocks, but I don't think it was in the right way.