title: JS: Turn CSV string, to: Object (map)
body: <p>How to code a pure JS.</p>
  <p>To transform CSV string:</p>
  <pre><code>col1,col2\na,b\nc,d
  </code></pre>
  <p>Into this object structure:</p>
  <pre><code>{&quot;a&quot;:[&quot;a&quot;,&quot;b&quot;],&quot;c&quot;:[&quot;c&quot;,&quot;d&quot;]...}
  </code></pre>
  <p>So it can br refered by eg.: Obj.c, to return:</p>
  <pre><code>[&quot;c&quot;,&quot;d&quot;]
  </code></pre>
  <p>Try to turn: <code>&quot;col1,col2\na,b\nc,d&quot;;</code></p>
  <p>into an array of array: <code>[['a','b'],['c','d']];</code></p>
  <p>Calling this: <code>CSVToArray(&quot;col1,col2\na,b\nc,d&quot;,&quot;,&quot;, true);</code></p>
  <pre><code>const CSVToArray = (data, delimiter = &quot;,&quot;, omitFirstRow = false) =&gt;
  data.slice(omitFirstRow ? data.indexOf(&quot;\n&quot;) + 1 : 0).split(&quot;\n&quot;).map(v =&gt; v.split(delimiter));
  </code></pre>
  <p>What about turn <code>&quot;col1,col2\na,b\nc,d&quot;;</code> into readable referral object structure (by first item on each line)?</p>
  <pre><code>var Obj =  {
                 &quot;a&quot;:[&quot;a&quot;,&quot;b&quot;],
                 &quot;c&quot;:[&quot;c&quot;,&quot;d&quot;],
                 ...
             }
  </code></pre>