Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

CSV blues

DolphPun Somme
The Pun is its own reword
Join date: 18 Nov 2005
Posts: 309
07-08-2006 03:28
ARRRRGGGGHHHHH!!!!! OK. Got that out of my system :eek:

I have been trying to bring in a simple CSV using llCSV2List

CSV = 123,"something with a comma, inside quotes"
(This is standard CSV) ("Comma Separated Value";)
the function SHOULD give...

[123],[something with a comma, inside quotes]
instead I get...
[123],["something with a comma],[inside quotes"]

Quotes are CSV standard for escaping strings... well batting my head against the wiki gave me the results...

CSV= 123,<something with a comma, inside GT/LT>

which gives
[123],[<something with a comma, inside GT/LT>]
(At this point I could just strip off the <> symbols... but that adds layers of lag)

So... is there any lsl standard way to escape the comma? ( and < / > symbols)

I have tried \, and other methods experimentation.

Lucy Linden was very good in trying to help me with this, but was unable to help.

CSV Doc: http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm


Guessing my only hope is the more complex llParseString2List but I am hoping its just an obscure incantation where I use a tilde or something else instead.
Jesse Malthus
OMG HAX!
Join date: 21 Apr 2006
Posts: 649
07-08-2006 10:49
LSL is not smart. Use llParseList2String if you need to use commas. I found that out the hard way with vectors >.<
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
07-08-2006 11:43
To get the literal backslash, use \\

Im afraid llList2CSV/llCSV2List dont work that way with quotes. What you could do, is on your receiving end strip out the quotes during element extraction rather then looping over the list after you create it.

In other words, instead of using llList2String, use:
CODE

string list2String(list src, integer index) {
string el = llList2String(src, index);
if (llGetListEntryType(src, index) == TYPE_STRING) {
if (llGetSubString(el, 0, 0) == "\"" && llGetSubStrinng(el, -1, -1) == "\"")
el = llGetSubString(el, 0, -2);
}
return el;
}


Hope this helps :)
==Chris