<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class DataTeleController extends Controller
{
    public function index()
    {
        $file = storage_path('app/public/dataTele_matang_dengan_klasifikasi.csv');
        $dt = $this->readCsv($file);

        return view('dataTele', ['dt' => $dt]);
    }

    private function readCsv($file)
    {
        $rows = [];
        if (($handle = fopen($file, 'r')) !== false) {
            while (($dt = fgetcsv($handle, 1000, ',')) !== false) {
                $rows[] = $dt;
            }
            fclose($handle);
        }
        return $rows;
    }
}
