ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jaroslav Hajtmar <hajtmar@gyza.cz>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Different versions of Lua and error in the same versions of ConTeXt (Fedora vs Win7)
Date: Tue, 24 Feb 2015 14:13:53 +0100	[thread overview]
Message-ID: <54EC7911.7020206@gyza.cz> (raw)
In-Reply-To: <54EAE98D.2030901@wxs.nl>

Hi Hans.
One more I ask You about this thing. When I have other separator - for 
example ";" then c.txt data file is:

first,second,third,fourth
"1";"2";"3";"4"
"a";"b";"c";"d"
"foo";"bar""baz";"boogie";"xyzzy"

I was unable to figure out how to set the separator (and others default 
values too) so as to replace the default value in the library util-prs.lua
Is there anything as utilities.parsers.rfc4180splitter.separator=";"???

This library is loaded automatically? Or as a module?

Thanks Jaroslav Hajtmar

Here is minimal example for Your correction:

\starttext

\startluacode

local mycsvsplitter = utilities.parsers.rfc4180splitter()
utilities.parsers.rfc4180splitter.separator=";"

local crap = io.loaddata("c.txt")

local list, names = mycsvsplitter(crap,true)   inspect(list) inspect(names)
local list, names = mycsvsplitter(crap)        inspect(list) inspect(names)

context.starttabulate { "|l|r|" }
for i=1,#list do
     local l = list[i]
     context.NC() context(l[1])
     context.NC() context(l[3])
     context.NC()
     context.NR()
end
context.stoptabulate()

\stopluacode

\stoptext





Dne 23.2.2015 v 9:49 Hans Hagen napsal(a):
> On 2/22/2015 9:42 PM, Pablo Rodriguez wrote:
>> On 02/22/2015 07:44 PM, Hans Hagen wrote:
>>> [...]
>>> for pablo: there are csv scanners built in context
>>
>> Hans,
>>
>> I don’t really need this at home, but I’m interested in this.
>
> in addition to the previous mail, t.txt is:
>
> first,second,third,fourth
> "1","2","3","4"
> "a","b","c","d"
> "foo","bar""baz","boogie","xyzzy"
>
> the code is in util-prs.lua (where all kind of parsing code lives)
>
> if you want to use that kind of code outside context you can do 
> something like this:
>
> lua mtxlibs.lua --selfmerge foo.lua
>
> and then in your script load foo.lua
>
> this makes it possible to use the same set of helpers in context as 
> well outside it (alternatively you can just use luatex as lua engine 
> and mtxrun as script runner which is what we mostly do); this means 
> that the context distribution provides all kind of means to set up 
> workflows
>
>> I guess you mean m-database.mkiv. But I don’t have a clue on how to
>> handle it.
>>
>> I mean, how to ignore the first line and how to make commands from the
>> so-called cells (A2, B5...; to use them in document combination) reading
>> an external file.
>>
>> Many thanks for your help,
>>
>> Pablo
>>
>
>

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  parent reply	other threads:[~2015-02-24 13:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-22 18:36 Jaroslav Hajtmar
2015-02-22 18:44 ` Hans Hagen
2015-02-22 19:40   ` Jaroslav Hajtmar
2015-02-22 20:42   ` Pablo Rodriguez
2015-02-23  8:36     ` Hans Hagen
2015-02-23  8:49     ` Hans Hagen
2015-02-23  9:25       ` Jaroslav Hajtmar
2015-02-24 13:13       ` Jaroslav Hajtmar [this message]
2015-02-24 13:46         ` Hans Hagen
2015-02-23  0:10 Akira Kakuto
2015-02-23  5:32 ` Jaroslav Hajtmar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54EC7911.7020206@gyza.cz \
    --to=hajtmar@gyza.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).