PHPackages                             8ctopus/nano-csv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. 8ctopus/nano-csv

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

8ctopus/nano-csv
================

Read csv and Excel xlsx files

1.4.0(5mo ago)0106MITPHPPHP &gt;=8.1CI passing

Since Aug 10Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/8ctopus/nano-csv)[ Packagist](https://packagist.org/packages/8ctopus/nano-csv)[ Docs](https://github.com/8ctopus/nano-csv)[ RSS](/packages/8ctopus-nano-csv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (23)Used By (0)

nano csv
========

[](#nano-csv)

[![packagist](https://camo.githubusercontent.com/78e5a7fd5b362b63f7a28f80db48754ebe0ae43b8807e20c9c000887716f4025/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f6e616e6f2d6373762f76)](https://packagist.org/packages/8ctopus/nano-csv)[![downloads](https://camo.githubusercontent.com/77661fd851ad9169a4e33b77cbffffd00c032af26ffbe9e4df11077204c89ee9/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f6e616e6f2d6373762f646f776e6c6f616473)](https://packagist.org/packages/8ctopus/nano-csv)[![min php version](https://camo.githubusercontent.com/8f4d70d6f1393b9b515f57e2edf5f28b4fbd158f14b65299ec363a02ce182a55/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f6e616e6f2d6373762f726571756972652f706870)](https://packagist.org/packages/8ctopus/nano-csv)[![license](https://camo.githubusercontent.com/abfb91e4018488a2936c0d36ae0db95c4b5c2c07968b05473d8a0f77a064eb96/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f6e616e6f2d6373762f6c6963656e7365)](https://packagist.org/packages/8ctopus/nano-csv)[![tests](https://github.com/8ctopus/nano-csv/actions/workflows/tests.yml/badge.svg)](https://github.com/8ctopus/nano-csv/actions/workflows/tests.yml)[![code coverage badge](https://raw.githubusercontent.com/8ctopus/nano-csv/image-data/coverage.svg)](https://raw.githubusercontent.com/8ctopus/nano-csv/image-data/coverage.svg)[![lines of code](https://raw.githubusercontent.com/8ctopus/nano-csv/image-data/lines.svg)](https://raw.githubusercontent.com/8ctopus/nano-csv/image-data/lines.svg)

Parse csv and Excel xlsx files

features
--------

[](#features)

- parse csv and Excel xlsx files
- no dependencies, fast and low memory footprint
- very small code base: 1100 lines of code
- auto detect file encoding and line endings
- auto detect csv separator, enclosure and header presence
- unicode support

install and demo
----------------

[](#install-and-demo)

```
composer require 8ctopus/nano-csv

```

- Simple csv parsing

```
use Oct8pus\CSV\CSV;

require_once __DIR__ . '/vendor/autoload.php';

$csv = new CSV(__DIR__ .'/samples/ascii-mac-header.csv');

echo $csv
    ->autoDetect() . PHP_EOL;

while ($row = $csv->readNextRow()) {
    echo implode(', ', $row) . PHP_EOL;
}
```

```
file: /dev/github/nano-csv/samples/ascii-mac-header.csv
size: 500
BOM: None
encoding: ASCII
line ending: Mac
lines count: 9
separator: ,
enclosure: "
header: true
rows count: 8
columns (13): Month, Average, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015

May, 0.1, 0, 0, 1, 1, 0, 0, 0, 2, 0, 0, 0
Jun, 0.5, 2, 1, 1, 0, 0, 1, 1, 2, 2, 0, 1
Jul, 0.7, 5, 1, 1, 2, 0, 1, 3, 0, 2, 2, 1
Aug, 2.3, 6, 3, 2, 4, 4, 4, 7, 8, 2, 2, 3
Sep, 3.5, 6, 4, 7, 4, 2, 8, 5, 2, 5, 2, 5
Oct, 2.0, 8, 0, 1, 3, 2, 5, 1, 5, 2, 3, 0
Nov, 0.5, 3, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1
Dec, 0.0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
```

- And some handy options

```
$csv = new CSV(__DIR__ .'/samples/ascii-mac-header.csv');

$csv
    ->autoDetect()
    // convert string to number
    ->setConvertNumbers(true)
    // return associative array
    ->setAssociativeArray(true);

$average = 0;

while ($row = $csv->readNextRow()) {
    $average += $row['Average'];
}

echo "Average from May to Dec: {$average}" . PHP_EOL;
```

```
Average from May to Dec: 9.6
```

- Excel xlsx parsing

```
use Oct8pus\CSV\XLSX;

$xls = new XLSX(__DIR__ .'/samples/test.xlsx');

echo $xls
    ->autoDetect() . PHP_EOL;

while ($row = $xls->readNextRow()) {
    echo implode(', ', $row) . PHP_EOL;
}
```

```
file: K:\dev\github\nano-csv/samples\test.csv
size: 174
BOM: UTF-8
encoding: UTF-8
line ending: Linux
lines count: 9
separator: ,
enclosure: none
header: true
rows count: 7
columns (5): name, class, weight, empty, height

cat, mammal, 8, , 0.2
rabbit, mammal, 0.6, , 0.2
dog, mammal, 20, , 0.7
puma, mammal, 30, , 0.6
pinguin, bird, 10, , 0.4
bear, mammal, 300, , 1
bat, mammal, 0.1, , 0.1
```

Also look at the `demo-*` files.

tests
-----

[](#tests)

```
composer test

```

clean code
----------

[](#clean-code)

```
composer fix
composer fix-risky

```

todo
----

[](#todo)

- use readonly properties
- detect escape char
- refactor read
- make a really tricky test file - detect escape character within enclosures
- compare performance against most popular csv parsers

credits
-------

[](#credits)

```
https://filesamples.com/formats/csv
https://eforexcel.com/wp/downloads-18-sample-csv-files-data-sets-for-testing-sales/

```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance71

Regular maintenance activity

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~57 days

Recently: every ~245 days

Total

22

Last Release

164d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dafd5f7ef8134a5c9b231686c5da3d6416db09139b45aac0b26952178dffb8a?d=identicon)[8ctopus](/maintainers/8ctopus)

---

Top Contributors

[![8ctopus](https://avatars.githubusercontent.com/u/13252042?v=4)](https://github.com/8ctopus "8ctopus (193 commits)")

---

Tags

csvexcelimportparserphpxlsxparserexcelxlsxcsvimportread

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/8ctopus-nano-csv/health.svg)

```
[![Health](https://phpackages.com/badges/8ctopus-nano-csv/health.svg)](https://phpackages.com/packages/8ctopus-nano-csv)
```

###  Alternatives

[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M130](/packages/openspout-openspout)[shuchkin/simplecsv

Parse and retrieve data from CSV files. Export data to CSV.

5192.4k](/packages/shuchkin-simplecsv)[dcat/easy-excel

使用简单实用的语义化接口快速读写Excel文件

155373.4k23](/packages/dcat-easy-excel)[avadim/fast-excel-reader

Lightweight and very fast XLSX Excel Spreadsheet Reader in PHP

104608.4k6](/packages/avadim-fast-excel-reader)[jgrygierek/batch-entity-import-bundle

Importing entities with preview and edit features for Symfony.

101.1M1](/packages/jgrygierek-batch-entity-import-bundle)[jgrygierek/sonata-batch-entity-import-bundle

Importing entities with preview and edit features for Sonata Admin.

10951.2k](/packages/jgrygierek-sonata-batch-entity-import-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
