3

How do you create CSV files?

I have a new Drupal Commerce website and I want to migrate all my products from my previous Drupal 7 Commerce site. I want to use the Feeds module to import my products.

I have not been able to find a way "to create a CSV file". Any suggestions?

How do I create a CSV file from my current drupal commerce to my new one?

2

You can use the Forena module. Here is a quote from that page:

... built of the idea of using SQL to get data out of a database and use XHTML and CSS to format it into web reports.

Here is another quote from Reasons for considering Forena, related to the "CSV" in the question here:

Reports created by Forena ... can be saved (exported) as PDF documents with embedded graphs. Other supported formats for saving a report are CSV, XLS, DOC, HTML, etc.

So if you'd install Forena in your "old" site, then these are the steps for creating such CSV files are:

  • a custom SQL query (where you have the full power of SQL at your fingertips, and various extra features related to it provided by Forena, such as using report parameters, conditional SQL, etc).
  • a custom report (either by an admin, or by just any regular user who is either familiar with creating what is called 'FRX files', or otherwise using the WYSIWYG report editor).
  • saving the report in (eg) CSV format, using one of the typical hyperlinks to do so in a report.

These steps do not require any PHP coding.

Bonus: instead of CSV format, you also have an option to format it as either XML or JSON. For more details on that, refer to "How to add a link to the CSV download to my module page, for a report created with Forena?".

Alternative: not sure if it would fit your requirements, but you could also use the Feeds integration of Forena. In this case you'd install Forena in your new site, and use Forena to enable Feeds to just go get your data in your old site. Checkout the video tutorial about this topic (specific to this Feeds integration).

For an online demo (prior to installing/testing Forena), checkout these links:

Disclosure: I'm a co-maintainer (not owner ...) of this module,
I hope this does not violate the site's policy on self-promotion.

  • Merci! But maybe not just the answer, but the module itself!?!? Also, have a look at the demo links near the end of drupal.stackexchange.com/questions/165554/… ... It may help to consider marking this answer here as accepted also (should you want to consider that, no obligation of course ...) – Pierre.Vriens Dec 8 '15 at 22:51
1

The tried and true method is to use Views with Views Data Export. CSV exports can work just fine or exporting small batches of products without a lot of extra information. However, if you have a bunch of HTML information or data that doesn't fit in CSVs (e.g. rich HTML), then you can also export to XML or JSON.

You can then use Feeds extensible parsers to parse the rich data and have it import as expected.

1

To extract your info you could use the Forena Reports module. Checkout this video tutorial Getting Started with Forena and/or the answer from @Pierre.Vriens to this question.


Another option, would be to extract all the fields individually as a CSV using phpmyadmin or any other database viewer. Then put them all into 1 CSV file using MS Excel.


The least technical option would be to create a View table of all your fields (using Views module) and then all you do is highlight all and copy and paste to MS Excel.

Use Microsoft Excel to create columns for each field.

  • Save As CSV (Comma delimited)(*.csv)

enter image description here

  • 1
    How would you get the data in Excel first (before you can save it as CSV)? Maybe use Forena (also)? – Pierre.Vriens Dec 7 '15 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.