Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12482 closed defect (cantfix)

Trac tab-delimited Export

Reported by: anonymous Owned by:
Priority: normal Milestone:
Component: report system Version:
Severity: normal Keywords: tsv
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Jun Omae)

I am trying to export my trac tickets-change history with following SQL-Query:

SELECT DISTINCT
t.id AS Ticket, 
t.description as Description,
group_concat ( tc.author, '; ') AS Author,
group_concat ( tc.field, '; ') AS Field
/*group_concat ( tc.oldvalue, '; ') AS Comments_Old */
group_concat ( tc.newvalue, '; ') AS Comments_New
FROM ticket t
LEFT JOIN ticket_change tc ON ( t.id=tc.ticket )
GROUP BY t.id, t.summary

Problem is that he puts a linebreak at the field 'Comments_New' like seen on the screenshot

Attachments (1)

problemstack.png (20.1 KB ) - added by anonymous 9 years ago.

Download all attachments as: .zip

Change History (8)

by anonymous, 9 years ago

Attachment: problemstack.png added

comment:1 by Jun Omae, 9 years ago

Component: generalreport system
Description: modified (diff)
Keywords: tsv added; Trac trac-import SQL-Query Sql tab-delimated import linebreak cr lf removed
Priority: highestnormal

comment:2 by Jun Omae, 9 years ago

Resolution: worksforme
Status: newclosed

Not a bug.

The newlines can be contained using double-quotes.

>>> import csv
>>> import sys
>>> writer = csv.writer(sys.stdout, delimiter='\t', quoting=csv.QUOTE_MINIMAL)
>>> writer.writerow(['abc', 'abc\ndef'])
abc     "abc
def"

comment:3 by anonymous, 9 years ago

ok thank you very much for your quick answer.

I am new to trac, so can I integrate the double-quotes to my SQL-Query?

comment:4 by anonymous, 9 years ago

I replaced my single quotes with double quotes but it didn't worked, there are still newlines

comment:5 by Jun Omae, 9 years ago

No, no. The tsv format allows that newlines can be contained in each field.

comment:6 by Jun Omae, 9 years ago

Resolution: worksformecantfix

If you dislike newlines in your tsv export, you can use REPLACE() function to remove newlines.

MySQL
GROUP_CONCAT(REPLACE(tc.newvalue, '\n', ''), '; ') AS Comments_New
SQLite
GROUP_CONCAT(REPLACE(tc.newvalue, CHAR(10), ''), '; ') AS Comments_New

InstallationIssue. Support and installation questions should be asked on the mailing list or IRC channel.

Last edited 9 years ago by Jun Omae (previous) (diff)

comment:7 by anonymous, 9 years ago

Thank you i tried your suggestion, we use MySQL, but the line breaks are still there it didn't worked..

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.