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?
Comments
Comment #1
ZenLax CreditAttribution: ZenLax commentedSame problem here
Comment #2
Steven Jones CreditAttribution: Steven Jones commentedCan you try with the latest dev version?
Comment #3
gmazuel CreditAttribution: gmazuel commentedSame problem. The strange is: I have two. One works, but the news no works.
Comment #4
Keithw CreditAttribution: Keithw commentedI'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
Comment #5
brentratliff CreditAttribution: brentratliff commentedSame exact problem with the newest dev. I have tried both CSV and XLS. Preview is correct, file export has only header row.
Comment #6
brentratliff CreditAttribution: brentratliff commentedI 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.
Comment #7
brentratliff CreditAttribution: brentratliff commentedI tried it with dev, marking to active.
Comment #8
IckZ CreditAttribution: IckZ commentedanything new? same problem here...
Comment #9
IckZ CreditAttribution: IckZ commentedgot 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 :).
Comment #10
anydigital CreditAttribution: anydigital commentedTHANK YOU SO MUCH IckZ!!!
Worked for me too.
Comment #11
fonant CreditAttribution: fonant commentedThis 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.
Comment #12
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions commentedI 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
Comment #13
Kris77 CreditAttribution: Kris77 commenteddrush -u 1 views-data-export view-name display-name filename
Works for me too.
Thanks @fonant