2

I have one CCK field called "Questions" with type "Long text".

I'm trying to export this value using views data export in CSV format.

Below is the text to export.

Some text, trying to export.

While export in CSV, I have got only partial data. ie, "Some text".

After comma "trying to export" value is missing in CSV.

Is there any way to get complete data?

Note: Other than "views_pre_render"

  • comma is used as a seperator for csv. try using some other symbol. Can you please try this hook_views_post_execute – Fazeela Abu Zohra Feb 16 '17 at 7:08
  • @FazeelaAbuZohra, trying to fix through views interface. – kalidasan Feb 16 '17 at 7:19
  • I have fixed this problem by using "XLS" format. – kalidasan Feb 17 '17 at 7:56
0

As an alternative to the 2 modules you're using, you could also try to use the Forena module (Disclosure: I'm a co-maintainer of it). 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.

And 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.

These are the steps for creating such CSV files are:

  • Create a custom SQL query, in which you have the full power of SQL at your fingertips (and various extra features related to it provided by Forena).

    Here is a (basic) SQL I'd use for answering this question:

    SELECT nid, title, type, uid

    FROM node

  • Create 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.

    Using the WYSIWIG editor, in about 10 secs (= a few mouse clicks later on) you'd have a report for which the layout (in XHTML) would look like this:

    <body>
    <div id="nodes_block" class="FrxTable FrxTable" frx:block="drupal_cust/nodes">List of all nodes in this site
    
    
    <table>
      <caption>Report caption</caption>
      <thead>
        <tr>
          <th>nid</th>
          <th>title</th>
          <th>type</th>
          <th>uid</th>
        </tr>
      </thead>
      <tbody>
        <tr id="nodes" frx:foreach="*">
          <td>{nid}</td>
          <td>{title}</td>
          <td>{type}</td>
          <td>{uid}</td>
        </tr>
      </tbody>
      </table>
    </div>
    </body>
    

    As part of "designing" this report, you should enable (within what is called "Document types") the option to export to CSV files (possible other options like XLS, DOC, PDF, etc also if appropriate).

    At then end just "Save" the design of such report. This will be used later on, to retrieve all the specs of your report, when you want to browse (run, execute) your report.

  • Browse the report (= enter its relative path, or click some menu link if your design included such link) and then use the CSV link in it to actually save (= export) the report in (eg) CSV format.

  • Note: 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?".

Example

Here is an example of (part of) a CSV file I created using the above approach:

nid,title,type,uid

33,Demo title,article,19

39,"Demo, with some commas in the title, just a test",article,1

72,Yet some other Article,article,8

73,Article with some field collection data,article

The above CSV file contains:

  • the typical CSV header in record 1 of it, whereas the values in this record correspond with what was requested in the report design, as specified with the <th>...</th> tags in the report layout.
  • 1 record for each result that was selected.
  • 1 specific record with a node title containing commas (shown with surrounding "...").

More info

For more info (prior to installing/testing Forena), checkout these links:

  • I don't want to write any custom query. But thanks for your option. – kalidasan Feb 17 '17 at 7:54
  • I can able to manage this issue, if we are going through custom CSV generate. I have fixed this issue using XLS format. – kalidasan Feb 17 '17 at 7:55

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.