Edgewall Software
Modify

Ticket #8165 (new defect)

Opened 3 years ago

Last modified 3 months ago

[PATCH] csv download doesn't process 'description' field

Reported by: pellatt@… Owned by:
Priority: normal Milestone: 0.14
Component: report system Version: 0.12dev
Severity: minor Keywords: csv, patch
Cc: thijstriemstra
Release Notes:
API Changes:

Description (last modified by rblank) (diff)

In a report that includes the ticket 'description' field, the text is processed by the wiki processor, but when I choose to download the report by clicking on 'comma-delimited-text', the 'description' field in the csv file is *not* processed.
E.g. I have a macro which displays its output correctly in the onscreen report, but just shows "[[MyMacro()]]" in the csv file.

Attachments

csv.patch (1.4 KB) - added by Thijs Triemstra <lists@…> 16 months ago.
csv2.patch (3.1 KB) - added by Thijs Triemstra <lists@…> 16 months ago.
render description as plain text

Download all attachments as: .zip

Change History

comment:1 Changed 3 years ago by rblank

  • Description modified (diff)

I'm sure I saw a duplicate of this, but I can't find it ATM.

comment:2 Changed 3 years ago by rblank

  • Milestone set to 1.0

I still can't find it, so yeah, good idea ;-)

comment:3 Changed 17 months ago by Thijs Triemstra <lists@…>

  • Cc lists@… added

Here's a patch that adds the description column, when selected in the ui:

  • trac/ticket/query.py

     
    10991099    def export_csv(self, req, query, sep=',', mimetype='text/plain'): 
    11001100        content = StringIO() 
    11011101        cols = query.get_columns() 
     1102 
     1103        if 'description' in query.rows: 
     1104            query.cols.insert(2, 'description') 
     1105 
    11021106        writer = csv.writer(content, delimiter=sep, quoting=csv.QUOTE_MINIMAL) 
    11031107        writer.writerow([unicode(c).encode('utf-8') for c in cols]) 
    11041108 

Column's row content still needs to be wiki-fied though.

Changed 16 months ago by Thijs Triemstra <lists@…>

comment:4 Changed 16 months ago by Thijs Triemstra <lists@…>

  • Milestone changed from unscheduled to 0.13

Here's a patch that renders the description column as html, with rendered macro output. It would be nice to have this in plain text but I couldn't find a trac api for getting a plain-text output of wiki content. Output:

id,summary,description,status,type,priority,milestone,component
1,sdsad,"<p>
<pre class=""wiki"">upgrade 

    Upgrade database to current version

</pre>
</p>
",new,defect,major,,component1
2,sdsadsa,"<p>
dsadsdsadasdas
</p>
",new,defect,major,,component1
3,sadsadsdasdas,"<p>
sadsadasd
</p>
",new,defect,major,,component1

Changed 16 months ago by Thijs Triemstra <lists@…>

render description as plain text

comment:5 Changed 16 months ago by Thijs Triemstra <lists@…>

  • Milestone changed from 0.13 to 0.12.2

I attached a new patch that renders the description as plain text instead of html. It also updates the csv export in the report section.

I wasn't sure how to render wiki content as plaintext so I added a utility method that does that. If there's a better way to render markup as text, let me know and I'll update the patch.

comment:6 Changed 16 months ago by Thijs Triemstra <lists@…>

  • Keywords csv, review added; csv removed
  • Summary changed from csv download doesn't process 'description' field to [PATCH] csv download doesn't process 'description' field

comment:7 follow-up: Changed 16 months ago by rblank

  • Milestone changed from 0.12.2 to 0.13

I don't think expanded HTML is better than unexpanded wiki text. Expanded plain text would be great, but as you have found out, we don't have a wiki_to_text() (yet). And just stripping the HTML tags would probably have such a bad formatting as to be unusable. More brainstorming needed, I guess.

While this is a defect, it's a big enough change that I'd prefer doing it on trunk. Changing the milestone back to 0.13.

comment:8 in reply to: ↑ 7 Changed 15 months ago by thijstriemstra

  • Cc thijstriemstra added; lists@… removed
  • Keywords patch added; review removed

Replying to rblank:

.... Expanded plain text would be great, but as you have found out, we don't have a wiki_to_text() (yet). ...

Is there a ticket for this? It would be my nr 1 trac enhancement request.

comment:9 follow-up: Changed 15 months ago by rblank

Let's try searching for wiki_to_text... No, there's not ticket explicitly for that.

comment:10 in reply to: ↑ 9 Changed 15 months ago by thijstriemstra

Replying to rblank:

Let's try searching for wiki_to_text... No, there's not ticket explicitly for that.

I created #9879 for wiki_to_text().

comment:11 Changed 13 months ago by philipp.meier@…

Just some more information:


Using a custom query with activated field 'Show under each result: description' produces the expected result in the web browser.

Using the same query but then clicking on 'Download in other formats:' the exported file does not contain the description field or its contents (irrespective of exact format, i.e. comma-delimited or tab-delimited text). This is not the expected result and should be corrected.

comment:12 Changed 12 months ago by cboos

  • Milestone changed from 0.13 to next-major-0.1X

comment:13 Changed 12 months ago by cboos

  • Milestone changed from next-major-0.1X to 0.14

comment:14 Changed 12 months ago by AdrianFritz

  • If manually added &col=description to custom query, you'll get the desired result (when export CSV/TSV you'll have a column with formated text)
    • Example: query?owner=~cboos&status=assigned&col=id&col=summary&col=description results this query

comment:15 follow-up: Changed 3 months ago by AdrianFritz

One more though: I think the original idea is to simply download description field contents as originally written (even if it has wiki markup). In this way, proposed patch fulfills the original request. As a use case, we need (very often) wiki marked text to download, mass process contents in a spreadsheet and then import data back to Trac.

comment:16 in reply to: ↑ 15 Changed 3 months ago by cboos

Replying to AdrianFritz:

One more though: I think the original idea is to simply download description field contents as originally written (even if it has wiki markup). In this way, proposed patch fulfills the original request. As a use case, we need (very often) wiki marked text to download, mass process contents in a spreadsheet and then import data back to Trac.

Sounds good. In later versions, we'll be able to "wiki format" using trac-admin, so if some fields of the exported file need further processing, this could be done in a script. Well, doing this processing on one column of a CSV file doesn't seem to be trivial given the lack of utilities for working on CSV files the "Unix way", but the use case you mentioned seems at least as useful as having the ability to export formatted description. Ideally both use cases should be easy to support, let's start with the easiest to implement ;-)

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will be changed from (none). Next status will be 'new'
The owner will be changed from (none) to anonymous. Next status will be 'assigned'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.