PHP Classes

PHP Import CSV Validation: Parse and validate imported CSV data

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 186 All time: 8,644 This week: 560Up
Version License PHP version Categories
csvimportvalidator 1.0.0GNU General Publi...5PHP 5, Parsers
Description 

Author

This class can parse and validate imported CSV data.

It can take a string with tabulate data formatted using the CSV format and converts the data into an array with all the values in the data rows and columns.

The class can also check the number of rows in the array that was previously passed by the class.

Picture of Ciaran Moore
  Performance   Level  
Name: Ciaran Moore <contact>
Classes: 5 packages by
Country: United Kingdom
Age: 38
All time rank: 2221103 in United Kingdom
Week rank: 180 Up5 in United Kingdom Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php

include('lib/classes/csvImport.php');

$csv = new csvImport();


$return_array = array();


$csv_file = $csv->csvstring_to_array(file_get_contents('includes/import.csv'), 0, ',','');

$i = intval(0);
foreach(
$csv_file as $row)
{
   
$check = $csv->checkColNums($row);


    if(
$check['return']=="error")
    {
       
$error = $check['errors'];
    }
    else
    {
       
$error = "";
    }

   
$return_array[] = array("row" => $i, "status" => $check['return'], "cols" => $check['cols'], "errors" => $error);
   
$i++;
}

$getArrays = $csv->seperatedArrays('includes/import.csv');

var_dump($getArrays);

//var_dump($return_array);

//var_dump($csv_file);
exit;


  Files folder image Files (5)  
File Role Description
Files folder imagetest (1 file, 2 directories)
Plain text file csvImport.php Class Class source
Plain text file LICENSE Lic. License text

  Files folder image Files (5)  /  test  
File Role Description
Files folder imageincludes (1 file)
Files folder imagelib (1 directory)
  Plain text file test.php Example Example script

  Files folder image Files (5)  /  test  /  includes  
File Role Description
  Plain text file import.csv Data Auxiliary data

  Files folder image Files (5)  /  test  /  lib  
File Role Description
Files folder imageclasses (1 file)

  Files folder image Files (5)  /  test  /  lib  /  classes  
File Role Description
  Plain text file csvImport.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:186
This week:0
All time:8,644
This week:560Up