PHP Classes

PHP Import CSV Validation: Parse and validate imported CSV data

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 186 This week: 1All time: 8,635 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: 411 Up12 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  
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  /  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  /  test  /  includes  
File Role Description
  Plain text file import.csv Data Auxiliary data

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

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:186
This week:1
All time:8,635
This week:560Up