On 11/23/2012 1:38 PM, Philipp Gesang wrote:
although csv is not a standard per se there is nevertheless an rfc: http://tools.ietf.org/html/rfc4180. Can we have an optional rfc-compliant parser as well? That entails interpreting the first line as field header if it consists entirely of unquoted fields -- neat feature as one can treat these as column identifiers to query fields in a more natural fashion.
i patched your version a bit: local mycsvsplitter = utilities.parsers.rfc4180splitter() local crap = [[ first,second,third,fourth "1","2","3","4" "a","b","c","d" "foo","bar""baz","boogie","xyzzy" ]] -- local list, names = mycsvsplitter(crap,true) -- local list = mycsvsplitter(crap) the flag tells to return a header Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------