title: Laravel CSV file reading Angular as front
body: <p>Good day everyone!</p>
  
  <p>I have a CSV file, inside this:</p>
  
  <p>1.453453,4.578413,0.314132,0.764312,0.123422
  2.453453,3.578413,0.764312,0.314132,0.123422
  3.453453,2.578413,0.123422,0.764312,0.314132
  4.453453,1.578413,0.314132,0.123422,0.764312</p>
  
  <p>To read this in postman this is my code:</p>
  
  <pre><code>    $keys = ['PGA', 'PGV', 'X-Axis', 'Y-Axis', 'Z-Axis'];
      $json = [];
      $path = Storage::path('upload/test.txt');
      $file = fopen($path, 'r');
      while (($line = fgetcsv($file)) !== false) {
           $json[] = array_combine($keys, $line);
      }
      fclose($file);
      return json_encode($json);
  </code></pre>
  
  <p>The output is :</p>
  
  <pre><code>[
      {
          "PGA": "1.453453",
          "PGV": "4.578413",
          "X-Axis": "0.314132",
          "Y-Axis": "0.764312",
          "Z-Axis": "0.123422"
      },
      {
          "PGA": "2.453453",
          "PGV": "3.578413",
          "X-Axis": "0.764312",
          "Y-Axis": "0.314132",
          "Z-Axis": "0.123422"
      },
      {
          "PGA": "3.453453",
          "PGV": "2.578413",
          "X-Axis": "0.123422",
          "Y-Axis": "0.764312",
          "Z-Axis": "0.314132"
      },
      {
          "PGA": "4.453453",
          "PGV": "1.578413",
          "X-Axis": "0.314132",
          "Y-Axis": "0.123422",
          "Z-Axis": "0.764312"
      }
  ]
  </code></pre>
  
  <p>but I need to add 'data:' before the data and be inside another <code>{}</code>:
  like this:</p>
  
  <pre><code>{    
    "data":  [
          {
              "PGA": "1.453453",
              "PGV": "4.578413",
              "X-Axis": "0.314132",
              "Y-Axis": "0.764312",
              "Z-Axis": "0.123422"
          },
          {
              "PGA": "2.453453",
              "PGV": "3.578413",
              "X-Axis": "0.764312",
              "Y-Axis": "0.314132",
              "Z-Axis": "0.123422"
          },
          {
              "PGA": "3.453453",
              "PGV": "2.578413",
              "X-Axis": "0.123422",
              "Y-Axis": "0.764312",
              "Z-Axis": "0.314132"
          },
          {
              "PGA": "4.453453",
              "PGV": "1.578413",
              "X-Axis": "0.314132",
              "Y-Axis": "0.123422",
              "Z-Axis": "0.764312"
          }
      ]
  }
  </code></pre>
  
  <p>I am using angular as my front end and i need this to be shown. so i need to add the said above. thanks for every help you give! I have to put ' data: ' to call it inside the web page.</p>
  
  <p>Thanks!</p>