Table of Contents

About

Encodes a CSV string to key-value data. Note that in the CSV keys will be in the even positions and values in the odd positions, such that if $x$ is the index of a key, its corresponding value will be at index $x+1$ in the input CSV.

Example Usage

When the function is called with:

wasCSVToKeyValueData("position, <1,1,0>,toggle, on")

it will return the key-value data:

position=<1,1,0>&toggle=on

Equivalence

Note that calling:

string data = wasCSVToKeyValueData("position, <1,1,0>, toggle, on");

is equivalent to:

string data = wasKeyValueEncode(llCSV2List("position, <1,1,0>, toggle, on"));

Code

This script was tested and works on OpenSim version 0.7.4!

///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0    //
///////////////////////////////////////////////////////////////////////////
string wasCSVToKeyValueData(string csv) {
    list temp = llCSV2List(csv);
    list data = [];
    do {
        data += llList2String(temp, 0) + "=" + llList2String(temp, 1);
        temp = llDeleteSubList(temp, 0, 1);
    } while(llGetListLength(temp) != 0);
    return llDumpList2String(data, "&");
}

fuss/data_structures/key-value_pairs/csv/from.txt ยท Last modified: 2019/01/03 01:38 (external edit)

Access website using Tor Access website using i2p


For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.