CSV parser fails when header is disabled
Hi, the rfc4180splitter function from util-prs.lua returns a empty table when the option to turn the first line into a header is disabled. The following example from the source %%%% begin example \starttext \startluacode 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) inspect(list) inspect(names) local list, names = mycsvsplitter(crap) inspect(list) inspect(names) \stopluacode \stoptext %%%% end example returns these tables: %%%% begin result table={ { "1", "2", "3", "4" }, { "a", "b", "c", "d" }, { "foo", "bar\"baz", "boogie", "xyzzy" }, } table={ "first", "second", "third", "fourth", } table={ } nil %%%% end result Wolfgang
On 12/23/2017 2:32 PM, Wolfgang Schuster wrote:
the rfc4180splitter function from util-prs.lua returns a empty table when the option to turn the first line into a header is disabled. fixed in next beta
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Dear Sirs Recently I moved to High Sierra with lua version 5.3. I make a dynamic library from GSL and Swig the I call meurandist.so I do: swig -lua meurandist.i gcc -I/usr/include/lua -c meurandist_wrap.c -o meurandist_wrap.o gcc -c meurandist.c -o meurandist.o gcc -fpic -bundle -undefined dynamic_lookup -llua -lgsl -lgslcblas -lm -Wall -I/usr/local/include -L/usr/local/lib meurandist_wrap.o meurandist.o -o meurandist.so In my old machine all I need to do for call this library are "sudo cp randist.so /usr/local/lib/lua/5.2” And then \startluacode require "meurandist" ARRAY_SIZE=100 arr=meurandist.new_int(ARRAY_SIZE) meurandist.rpoisson(arr,ARRAY_SIZE,4) for i=0,ARRAY_SIZE-1 do context(" "..meurandist.int_getitem(arr,i)..",") end \stopluacode Works nicely. But now I don’t have lua 5.2 installed. I have copied my dynamic library in the lua5.3 tree and that works fine if I call them from the console, but not works if all call inside a context document. Did I need to install lua 5.2? Is it mandatary? Is there a another way to call c libraries? Thanks a lot and have a luck year. Jorge
On 12/26/2017 9:19 PM, Jorge Manuel wrote:
Dear Sirs
Recently I moved to High Sierra with lua version 5.3.
I make a dynamic library from GSL and Swig the I call meurandist.so
I do:
swig -lua meurandist.i gcc -I/usr/include/lua -c meurandist_wrap.c -o meurandist_wrap.o gcc -c meurandist.c -o meurandist.o gcc -fpic -bundle -undefined dynamic_lookup -llua -lgsl -lgslcblas -lm -Wall -I/usr/local/include -L/usr/local/lib meurandist_wrap.o meurandist.o -o meurandist.so
In my old machine all I need to do for call this library are
"sudo cp randist.so /usr/local/lib/lua/5.2”
And then
\startluacode require "meurandist" ARRAY_SIZE=100 arr=meurandist.new_int(ARRAY_SIZE) meurandist.rpoisson(arr,ARRAY_SIZE,4) for i=0,ARRAY_SIZE-1 do context(" "..meurandist.int_getitem(arr,i)..",") end \stopluacode
Works nicely.
But now I don’t have lua 5.2 installed. I have copied my dynamic library in the lua5.3 tree and that works fine if I call them from the console, but not works if all call inside a context document.
Did I need to install lua 5.2? Is it mandatary? Is there a another way to call c libraries?
Thanks a lot and have a luck year.
lua 5.3 has different 'number' internals so i think that 5.3 libs will not work with 5.2 anyway, you can probably best install lua 5.2 (otherwise, you also might need to adapt existing lua code to 5.3) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
No dia 27/12/2017, às 09:31, Hans Hagen
escreveu: On 12/26/2017 9:19 PM, Jorge Manuel wrote:
Dear Sirs Recently I moved to High Sierra with lua version 5.3. I make a dynamic library from GSL and Swig the I call meurandist.so I do: swig -lua meurandist.i gcc -I/usr/include/lua -c meurandist_wrap.c -o meurandist_wrap.o gcc -c meurandist.c -o meurandist.o gcc -fpic -bundle -undefined dynamic_lookup -llua -lgsl -lgslcblas -lm -Wall -I/usr/local/include -L/usr/local/lib meurandist_wrap.o meurandist.o -o meurandist.so In my old machine all I need to do for call this library are "sudo cp randist.so /usr/local/lib/lua/5.2” And then \startluacode require "meurandist" ARRAY_SIZE=100 arr=meurandist.new_int(ARRAY_SIZE) meurandist.rpoisson(arr,ARRAY_SIZE,4) for i=0,ARRAY_SIZE-1 do context(" "..meurandist.int_getitem(arr,i)..",") end \stopluacode Works nicely. But now I don’t have lua 5.2 installed. I have copied my dynamic library in the lua5.3 tree and that works fine if I call them from the console, but not works if all call inside a context document. Did I need to install lua 5.2? Is it mandatary? Is there a another way to call c libraries? Thanks a lot and have a luck year. lua 5.3 has different 'number' internals so i think that 5.3 libs will not work with 5.2
anyway, you can probably best install lua 5.2 (otherwise, you also might need to adapt existing lua code to 5.3)
Hans
My library works fine with lua 5.3, but I don’t know to fix that inside ConTeXT tree. Install lua 5.2 is the best and easy way. Thanks a lot Jorge
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl http://www.pragma-ade.nl/ | www.pragma-pod.nl http://www.pragma-pod.nl/ ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl mailto:ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl http://www.pragma-ade.nl/ / http://context.aanhet.net http://context.aanhet.net/ archive : https://bitbucket.org/phg/context-mirror/commits/ https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net http://contextgarden.net/ ___________________________________________________________________________________
On 12/27/2017 10:59 AM, Jorge Manuel wrote:
My library works fine with lua 5.3, but I don’t know to fix that inside ConTeXT tree. Install lua 5.2 is the best and easy way. beware of subtle differences:
4.0 vs 4 being printed (string.format in lua 5.3 is also more strict with int vs float) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Jorge Manuel
-
Wolfgang Schuster