GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - unicframework/csv-parser: CSVParser library parse csv data to array, object, and json format. CSVParser convert array, object, json to csv format.

BranchesTags
Open more actions menu

Latest commit

 

History

42 Commits
42 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
_config.yml
_config.yml
 
 
composer.json
composer.json
 
 
logo.jpg
logo.jpg
 
 

Repository files navigation

CSVParser

Unic Logo

CSVParser library parse csv data to array, object, and json format. CSVParser convert array, object, json to csv format.

Features

  • Parse data from csv file, array, json and objects.
  • Parse csv to array and array to csv.
  • Parse csv to object and object to csv.
  • Parse csv to json and json to csv.
  • Set custom headers to csv file.

Installation

  • Install composer if you have not installed.
composer require unicframework/csv-parser

Parse Data

use CSVParser\CSV;

$csv = new CSV();

//Parse data from csv file
$csv->parse('data.csv');

//Parse array data
$csv->parse($arrayData);

//Parse object data
$csv->parse($jsonData);

//Parse json data
$csv->parse($objectData);

Get Parsed Data

//Get header
$header = $csv->getHeader();

//Get parsed data to array format
$data = $csv->toArray();

//Select data from parsed data
$data = $csv->toArray(['Name', 'Email']);

//Get parsed data to object format
$data = $csv->toObject();

//Select data from parsed data
$data = $csv->toObject(['Name', 'Email']);

//Get parsed data to json format
$data = $csv->toJson();

//Select data from parsed data
$data = $csv->toJson(['Name', 'Email']);

//Get parsed data to csv format
$data = $csv->toCsv();

//Select data from parsed data
$data = $csv->toCsv(['Name', 'Email']);

Get Row Count

//Get row count
$rows = $csv->rowCount();

//Get header count
$cols = $csv->headerCount();

Select Data Limit

//Select 10 records
$csv->limit(10);
$data = $csv->toArray();

//Select from 5 to 10 records
$csv->limit(5, 10);
$data = $csv->toArray();

Set CSV Header

//Ignore header from csv file
$csv->ignoreHeader(true);

//Ignore csv header cse
$csv->ignoreHeaderCase(true);

//Ignore csv enclosure
$csv->ignoreEnclosure(true);

//Set header offset of csv file
$csv->headerOffset(0);

//Set custom header to csv file
$csv->setHeader(['Name', 'Email']);

Set CSV Delimiter

Default csv delimiter is , but we can set other delimiter for csv file.

//Set delimiter
$csv->setDelimiter('|');

//Set enclosure
$csv->setEnclosure('"');

//Set escape character
$csv->setEscape('//');

//Parse csv file data
$csv->parse('data.csv');

//Get data from parsed data
$data = $csv->toArray();

Aggregate Functions

//Parse csv file data
$csv->parse('data.csv');

//Get total sum of given field
$total_price = $csv->sum('price');

//Get minimum from given field
$min_price = $csv->min('price');

//Get maximum from given field
$max_price = $csv->max('price');

//Get average of given field
$average_price = $csv->average('price');

License

MIT License

About

CSVParser library parse csv data to array, object, and json format. CSVParser convert array, object, json to csv format.

unicframework.github.io/csv-parser

Topics

csv-exportcsv-importcsv-parsercsv-to-arraycsv-to-jsoncsvparserphp-csv

Resources

Readme
MIT license
Activity
Custom properties

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.