[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Importing tab-delimited text files or connecting to ODBC
From: |
Maks Romih |
Subject: |
Importing tab-delimited text files or connecting to ODBC |
Date: |
16 Feb 2006 09:44:20 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
Hi all!
I have a question about lisp in Emacs for Windows
What would be the best way to import some tables, like a tab delimited
copy-paste chunk from excel. I would like to get the table into Emacs
Lisp so that a table would be a big list of rows, where a row would be
a list of atoms, either raw strings or, when possible, converted to
Lisp numbers and symbols.
I'm considering programming some low level function like
>(defun read-tab-delimited (fn)
> (find-file fn)
> (let (row rows)
> (while (re-search-forward "\\([^
>]*\\)\\([
>]\\)" nil t)
> (let ((token (match-string 1)))
> (push token row)
> (when (equal (match-string 2) "
>")
> (push (nreverse row) rows)
> (setq row nil))))
> (kill-buffer nil)
> (nreverse rows)))
but I don't like it. I would still have a lot to work with converting
strings into numbers, converting pairs of double quotes into single
quotes, etc.
It would be much better if I could somehow call ODBC from emacs. Then
I would simply connect to some Microsoft Access MDB or any other
relational database, and pump the data from there.
If the ODBC is impossible to call from emacs, I would maybe use CLISP
and CLSQL to connect to ODBC, convert the data and then load data into
emacs with the Elisp function read. I'm not sure if CLSQL and CLISP
for Cygwin works, this I'm going to ask on the comp.lang.lisp.
If someone of you had similar problems and have some idea, I would be
greatly thankful for any suggestions.
Maks.