lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi all,

Recently we were talking about CSV format again, and there was a
suggestion that we needed a fast low-level extension [1]

Well, [2] is an attempt to supply that extension.  It does the quoting
rules correctly, as far as I can tell, but does not do the case where
multiline records are encoded in double-quotes.  That is an exercise
for another day.

It provides an iterator, which returns the _same table_  each time. So
for a little inconvenience in some cases, one gets absolutely minimal
hit on Lua memory. The returned table does have a copy() method,

By default, it looks at the first data line and works out whether they
are to convertible to numbers. Thereafter, it keeps a mask of these
fields and converts them. This will particuarly help you if you have a
lot of numerical data to bring in.  (You can always switch it off if
it guesses incorrectly)

Tested on Debian 32-bit (gcc), and Windows XP (MS compiler).  The zip
contains a dll for those poor Windows souls without compilers.

steve d.