Solution

Add the '-u 1' option to your Drush command, then the export is done as User-1.

Question

My view produces correct output in the view preview and I can download a good CSV by pointing a browser at the path URL. However, I cannot produce a usefull file using drush.

Here is my drush command (on Ubuntu localhost):
sudo drush views-data-export my_csv_export views_data_export_1 export.csv

If the view is set to batch export a file is created but it only contains the column headers (and contains no data rows).

If the view is set to not batch export no file is created at all - the output (of only column headers) is printed to the terminal.

I am new to both drush and views data export. I guess I am missing something obvious. How do I produce a file that contains data rows?

CommentFileSizeAuthor
#4 drush.txt2.23 KBKeithw
#4 drupal_error.txt454 bytesKeithw
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ZenLax’s picture

Same problem here

Steven Jones’s picture

Status: Active » Postponed (maintainer needs more info)

Can you try with the latest dev version?

gmazuel’s picture

Same problem. The strange is: I have two. One works, but the news no works.

Keithw’s picture

FileSize
454 bytes
2.23 KB

I'm getting the same problem with an xml export. See attached for drush debug info and the error message from the site logs. Hope it helps.

Keith

brentratliff’s picture

Same exact problem with the newest dev. I have tried both CSV and XLS. Preview is correct, file export has only header row.

brentratliff’s picture

I tried beta 5 and beta 6 as well with PHP 5.3. I tried dev with PHP 5.2, 5.3, and 5.4. Same result.

brentratliff’s picture

Status: Postponed (maintainer needs more info) » Active

I tried it with dev, marking to active.

IckZ’s picture

Issue summary: View changes

anything new? same problem here...

IckZ’s picture

got it for my problem..

It seems to be an issue with the requested commerce data (in my case). If I turn on "Disable SQL Rewriting" in the querry-settings everything works as it should :).

anydigital’s picture

THANK YOU SO MUCH IckZ!!!

Worked for me too.

fonant’s picture

This is probably due to access permissions: if your data export view requires a certain permission you need to tell drush which user to log in as to run the export. The "super-user" UID 1 will always have permission.

Instead of turning off SQL rewriting (which removes access permission checks to the view), try running with -u 1 as a drush command option:

drush -u 1 views-data-export view-name display-name filename

This works for me. The view is still protected against anonymous access, but drush can export the data.

helmo’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

I also was confused by this for a moment ... but adding the '-u 1' option is the best solution.

Added a pull request to Drush to improve the docs, https://github.com/drush-ops/drush/pull/2201

Kris77’s picture

drush -u 1 views-data-export view-name display-name filename

Works for me too.

Thanks @fonant