survos / grid-group-bundle

将CSV组处理成电子表格

资助包维护!
kbond

安装数: 1,671

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 3

分支: 0

公开问题: 0

类型:symfony-bundle

1.5.340 2024-07-06 14:55 UTC

This package is auto-updated.

Last update: 2024-09-24 13:45:05 UTC


README

正在开发中!很可能会被Pixy/Pixie/KeyValue bundle取代,后者使用Sqlite而不是csv。但这里的一些工具可能会有所帮助。

将一组CSV文件作为数据库处理的包。想法是避免在数据导入过程中创建临时实体或模型。

CsvParser

CSV Reader 类是读取csv记录的绝佳方式。

$csv = Reader::createFromPath('/path/to/file.csv', 'r');
$csv->setHeaderOffset(0);
$header_offset = $csv->getHeaderOffset(); //returns 0
$header = $csv->getHeader(); //returns ['First Name', 'Last Name', 'E-mail']

示例:创建一个简单的相关表。

给定一个电影CSV表,创建一个CsvDatabase(GridGroup?)

id,title,poster,overview,release_date,genres
287947,Shazam!,https://image.tmdb.org/t/p/w500/xnopI5Xtky18MPhK40cZAGAOVeV.jpg,"A boy is given the ability to become an adult superhero in times of need with a single magic word.",1553299200,"Action, Comedy, Fantasy"
299537,"Captain Marvel",https://image.tmdb.org/t/p/w500/AtsgWhDnHTq68L0lLsUrCnM7TjG.jpg,"The story follows Carol Danvers as she becomes one of the universe’s most powerful heroes when Earth is caught in the middle of a galactic war between two alien races. Set in the 1990s, Captain Marvel is an all-new adventure from a previously unseen period in the history of the Marvel Cinematic Universe.",1551830400,"Action, Adventure, Science Fiction"

创建movie.csv和genre.csv,其中genre counts作为一个额外字段

我们需要一个模式来定义输出csv数据库,我们可以通过命名字段来创建它。

$gridGroup = new GridGroup('movie_and_genre');
$grid = (new \Survos\GridGroupBundle\Model\Grid('movie'));
$grid->addRow()

定义模式