<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Priya Bansal</title>
    <description>The latest articles on DEV Community by Priya Bansal (@priyabnsal).</description>
    <link>https://dev.to/priyabnsal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F944536%2F5224d88d-1d5a-4290-9243-e3f9b09b1b93.png</url>
      <title>DEV Community: Priya Bansal</title>
      <link>https://dev.to/priyabnsal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/priyabnsal"/>
    <language>en</language>
    <item>
      <title>Parser for TXT and CSV file without any 3rd Party Library</title>
      <dc:creator>Priya Bansal</dc:creator>
      <pubDate>Sat, 15 Oct 2022 07:20:32 +0000</pubDate>
      <link>https://dev.to/priyabnsal/parser-for-txt-and-csv-file-without-any-3rd-party-library-4f8p</link>
      <guid>https://dev.to/priyabnsal/parser-for-txt-and-csv-file-without-any-3rd-party-library-4f8p</guid>
      <description>&lt;p&gt;Hi, this is the code for Parser purely based on javascript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export const csvToArray = (fileContent, rows, delimiter) =&amp;gt; {
  let splittedFileContent = fileContent?.split('\n')
  let newRows = splittedFileContent.slice(0, rows)

  if (newRows.length === 0) {
    return
  } else {
    // Counting max delimiter and
    //Splitting columns based on max delimiters in the splitterFileContent based on user Input
    const headers = delimiter
      ? [
          ...Array(
            Math.max(
              ...newRows.map((row) =&amp;gt; (row.split(delimiter) ?? []).length),
            ),
          ).keys(),
        ]
      : [0]

    const arr = newRows.map((row) =&amp;gt; {
      const values = delimiter ? row.split(delimiter) : [row]
      const el = headers.reduce(function (object, header, index) {
        object[header] = values[index]
        return object
      }, {})
      return el
    })
    //converting array of object into array of array
    const result = arr.map(Object.values)
    return result
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/priyabnsal/Parsing-txt-And-CSV-file"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Connect with me on:&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/priyaabnsal/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
