This could be a D8 feeds questions... looking for code examples.

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
IrishGringo's picture

I was looking for D8 code to create Nodes from a cvs file. I understand that this would normally be the work of a feeds module. But as D8 is kind of new, and I have this requirement anyway, I wanted to create a module that will create a couple of custom node/content types.. then populate the nodes with about 30 records from a cvs file.
My use case is that this would be a way to create a site with just modules, including real data. Then feeds could take over afterwards.
I also want to create the Views for these content types.

My thought is that the module could be edited to change the content types, as well as insert a CSV file for the data... then just install the module, and you get the content and data together.

I have a hunch features may be an option but not sure.

So, can I get some hints on how this would be done programatically. Perhaps some sample code I would look at. Perhaps there is a DRUSH command that will do this?

This would help a lot as I have a new D8 site that will have 6 content types with some initial data. This is a lot of work, and I would prefer to do it as some kind of module.

Comments

The D8 multilingual demo

--
Christian López Espínola (@penyaskito)

Migrate does this...

Ryan Weal's picture

You can define a migration for CSV files using just config, using migrate_source_csv module and run it with drush: https://www.drupal.org/project/migrate_source_csv

Drupal 8 production sites

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week