Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Laravel Read CSV File

 if (!empty($request->files) && $request->hasFile('csv_file')) {
                $file = $request->file('csv_file');
                $type = $file->getClientOriginalExtension();
                $real_path = $file->getRealPath();
                if ($type <> 'csv') {
                    Alert::error('Wrong file extension', 'Only CSV is allowed')->persistent('close');
                    return redirect()->back();
                }
                $data = $this->readCSV($real_path, array('delimiter' => ','));
            }
Comment

laravel import data from csv

function csvToArray($filename = '', $delimiter = ',')
{
    if (!file_exists($filename) || !is_readable($filename))
        return false;

    $header = null;
    $data = array();
    if (($handle = fopen($filename, 'r')) !== false)
    {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== false)
        {
            if (!$header)
                $header = $row;
            else
                $data[] = array_combine($header, $row);
        }
        fclose($handle);
    }

    return $data;
}
Comment

how can we merge csv file in laravel

<?php
function joinFiles(array $files, $result) {
    if(!is_array($files)) {
        throw new Exception('`$files` must be an array');
    }

    $wH = fopen($result, "w+");

    foreach($files as $file) {
        $fh = fopen($file, "r");
        while(!feof($fh)) {
            fwrite($wH, fgets($fh));
        }
        fclose($fh);
        unset($fh);
        fwrite($wH, "
"); //usually last line doesn't have a newline
    }
    fclose($wH);
    unset($wH);
}
Comment

PREVIOUS NEXT
Code Example
Php :: keep track of view count php 
Php :: laravel connection timed out 
Php :: PHP DOMDocument, Unicode problems 
Php :: Laravel - foreach on collection 
Php :: Target class [HomeController] does not exist. 
Php :: what returns livewire mount 
Php :: how to use “find_in_set” in cakephp 3 find method 
Php :: php xpath get all tags under a tag 
Php :: laravel retain old value 
Php :: wp post view1 
Php :: in packagemanifest.php line 131 undefined index name 
Php :: Laravel/Php Carmel Casing / Title Casing 
Php :: morph laravel without classes name 
Php :: check input value is not empty or spaced php 
Php :: laravel-5-on-shared-hosting-wrong-public-path 
Php :: the_fiel 
Php :: Ciclo for PHP ejemplos 
Php :: laravel model undefined property 
Php :: laravel General error: 1215 Cannot add foreign key constraint" 
Php :: php set 404 page 
Php :: php send data from one page to another 
Php :: woocommerce check if shop page 
Php :: artisan command to add resources to controller 
Php :: php cheat sheet 
Php :: Syntax error or access violation: 1055 
Php :: views_pre_view 
Java :: camera permission android 
Java :: convert input stream to string java 
Java :: find maven version 
Java :: java hashmap entryset 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =