list - Mathematica - Separate elements of a string into columns? -


i'm producing encoded output list of strings lists. there way turn them actual lists can select elements , format them columns? or way select characters in strings , put in columns?

  button[     "run",     {afit = input["please enter id#", deleteme] ;     clearall[dat],     dat := traumaencoding@afit;     clearall[funcel],     funcel[p_string] :=      which[stringmatchq[       p, ("*no new ones*" | "*no new marks*" |        "*old wounds healing*"),        ignorecase -> true], "0",       stringmatchq[p, ("*abrasion*"), ignorecase -> true], "{1,0}",       stringmatchq[p, ("*lacer*"), ignorecase -> true], "{1,1}",       stringmatchq[p, ("*punct*") | ("*pct*"),        ignorecase -> true], "{1,2}",       stringmatchq[p, ("*amput*"), ignorecase -> true], "{1,4}",       stringmatchq[        p, ("*wound*" | "*injur*" | "*trauma*" |         "*swollen*" | "*swell*"), ignorecase -> true], 1, true, 0];     funcel[___] := 0;     clearall[func],     func[l_list] :=       which[memberq[map[funcel, l], "0"], "0",        memberq[map[funcel, l], "{1,4}"], "{1,4}",        memberq[map[funcel, l], "{1,2}"], "{1,2}",        memberq[map[funcel, l], "{1,1}"], "{1,1}",        memberq[map[funcel, l], "1-0"], "1,0", memberq[map[funcel, l], 1],        1, true, 0];     listo := map[func, dat]},   background -> yellow, sequence @@ $buttonoptions   ] 

produces this:

   {"{1,2}", "{1,2}", "0", "{1,2}", "0", "0", "0", "0", "0"} 

i need turn more this, ideally can export excel file:

    header  header       1       2       1       2       0       1       2       0      etc., 

toexpression["{1,2}"]  ==> {1,2} 

or whole list:

data =  prepend[toexpression /@ {"{1,2}", "{1,2}", "0", "{1,2}", "0", "0",      "0", "0", "0"}, {"header1", "header2"}]  (* ==> {{"header1", "header2"}, {1, 2}, {1, 2}, 0, {1 2}, 0, 0, 0, 0, 0}   *) 

formatted table:

enter image description here

to export:

export["filename.csv", data] 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -