title: Importing CSV file in MVC and converting it in JSON using C#
body: <p>I am importing .CSV file from an angular app into MVC and i am able to get the files like this</p>
  
  <pre><code>Int32 strLen, strRead;
              System.IO.Stream stream = Request.InputStream;
              strLen = Convert.ToInt32(stream.Length);
              byte[] strArr = new byte[strLen];
              strRead = stream.Read(strArr, 0, strLen);
  </code></pre>
  
  <p>here the files which is being imported is converted into <strong>byte[]</strong> because i am reading the file using </p>
  
  <blockquote>
    <p>System.IO.Stream stream = Request.InputStream</p>
  </blockquote>
  
  <p>Then i convert it into string like this </p>
  
  <pre><code> string a = System.Text.Encoding.UTF8.GetString(strArr);
  </code></pre>
  
  <p>and try to split the content and retrieve the data but it becomes very complex, i wonder if there is any alternate way for it. In a simple .CSV file like this</p>
  
  <p><a href="https://i.stack.imgur.com/gE37l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gE37l.png" alt="enter image description here"></a>
  I get the result after converting the byte[] to string like this</p>
  
  <p><a href="https://i.stack.imgur.com/GFdpm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GFdpm.png" alt="enter image description here"></a></p>
  
  <p>and once i apply logic for splitting the string and retrieving the data, the logic gets very messy like this</p>
  
  <p><a href="https://i.stack.imgur.com/tTudv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tTudv.png" alt="enter image description here"></a></p>
  
  <p>Is there any efficinet way where i can convert the imported .CSV file to JSON</p>