| Name | CSV Macro |
|---|---|
| Download | See Table Plugin |
| Issue Tracking | http://developer.atlassian.com/jira/browse/TBL |
Description
Convert csv and other deliminated data into a Confluence table. CSV is not a formal standard, but the best reference is The Comma Separated Value (CSV) File Format. The support in this macro comes close to following this pseudo-standard (see SCRP-16).
Documentation
Parameters
In addition to the parameters listed below, this macro supports Common table capabilities.
- output - Determines how the output is formated:
- html - Data is output as a HTML table (default).
- wiki - Data is output as a Confluence wiki table. Use this option if you want data within the table to be formated by the Confluence wiki renderer.
- script - Location of csv data. Default is the macro body only. If a location of data is specified, the included data will follow the body data.
- #filename - Data is read from the file located in /script/filename. Subdirectories can be specified.
- global page template name - Data is read from a global page template.
- space:page template name - Data is read from a space template.
- ^attachment - Data is read from an attachment to the current page.
- page^attachment - Data is read from an attachment to the page name provided.
- space:page^attachment - Data is read from an attachment to the page name provided in the space indicated.

Subject to change Expect changes to the script parameter name and how included data is referenced in the future.
- heading - Number of rows to be considered heading rows (default is 1 row). Specify heading=false or heading=0 to not show any heading lines. Heading rows do not participate in sorting.
- border - The border width in pixels. Defaults to normal table border width.
- width - The table width in pixels. Default is 100%.
- delimiter - Delimiter that separates columns.
- , (comma) - The default column separator.
- whitespace - Blanks, tabs, and other white space are used to separate columns.
- blanks - Blank or blanks only.
- pipe - '|'
- other single character delimiter - may be within double quotes with some restictions. Examples: ";" and "=" work. "|" does not.
- quote - the character used to represent quoted data. Quoted data may contain delimiters or new lines. Quote character data must be doubled inside a quoted string.
- double - Double quote character (default).
- single - Single quote character.
- escape - The '|' character in data can cause formatting of the table to be incorrect because it is interpreted as a column boundary. Set escape=true to allow this character to be escaped so that it will not affect the formatting. The default is false so that things like wiki links are handled correctly.
- showWiki - Default is false. Set to true to show a non-formatted version of the wiki table following the formatted table. This is used to help resolve formating issues.
Adding headings to existing data
- The body of the macro will be added to the top of any included data from attachments, so heading text can be added to data that does not have headings.
Usage Examples
Simple comma separated data
{csv}
, January, February, March, April
Max, 37.5, 32.7, 28.0, 25.3
Min, 31.3, 26.8, 25.1, 18.7
{csv}
Whitespace separated data with wiki formating
{csv:output=wiki|width=900|border=15|delimiter=whitespace}
Month Max Min Average
January 25.5 *6.3* 15.9
February 32.4 12.8 22.6
March 44.6 24.5 34.6
April 59.7 37.1 48.4
May 72.5 48.7 60.6
June 81.3 57.9 69.6
July 85.2 62.8 74
August 82.5 60.7 71.6
September 73.7 51.7 62.7
October 61.1 40.1 50.6
November 43.6 27.4 35.5
December 29.9 13.6 21.8
{csv}
Compatibility With Other Macros
- Confluence Chart Plugin - can be used to create data for a chart
- Beanshell Macro - to generate csv macro and data as output from Java code (use output=wiki)
- Groovy Macro - to generate csv macro and data as output from Groovy code (use output=wiki)
- Jython Macro - to generate csv macro and data as output from Jython code (use output=wiki)

Comments (16)
Dec 10, 2005
Mike Cannon-Brookes says:
Bob, Great macro! The logical next step, of course, is Excel spreadsheets. ...Bob,
Great macro! The logical next step, of course, is Excel spreadsheets.
Given that Confluence includes POI already (to read data from Excel files for the Excel search extractor) it would be relatively trivial to write the same thing for Excel!
That would be present worksheet X from Excel spreadsheet attached/on page Y/url Z as a table within Confluence.
Also, beware that reading external files is always dangerous. I'm not so sure the 'read CSV file X' is a good idea because it present a lot of power to the user they're not aware of. What about reading /etc/passwd or /etc/groups? Should a normal Confluence user be able to use Confluence to read and present those files?
Anyway, great work so far!
Cheers,
Mike
Dec 10, 2005
Bob Swift says:
Mike, thanks. Yes, I agree Excel is even more interesting. In fact, I have con...Mike, thanks. Yes, I agree Excel is even more interesting. In fact, I have content that is in Excel that I want to include. Right now that is being done by convert/copy/paste. I am aware of the POI stuff and I will see how easy it is to integreate. I am also aware of the security issues with this and the other script macros (Security) and hope with your help we can eventually get this controlled. Although, I believe the script macros are restricted to files from a pre-defined path (../home/script/...). Of course code that is allowed to run is not restricted at all which is why we need some special security.
Dec 11, 2005
Bob Swift says:
See SCRP-13 and SCRP-15See SCRP-13 and SCRP-15
Dec 21, 2005
Bob Swift says:
As it turned out, there is an API library that supported formulas, so decided to...As it turned out, there is an API library that supported formulas, so decided to use that at least until POI improves. See [excel macro].
Apr 06, 2006
Russell Warren says:
What is wrong with the csv table below? {csv:delimiter=[;]} ; Col 1 ; Col 2 ...What is wrong with the csv table below?
{csv:delimiter=[;]} ; Col 1 ; Col 2 ; Col 3 ; Col 4 R1 ; 1 ; 2 ; 3 ; 4 R2 ; 6 ; 4 ; 9 ; 2 R3 ; 8 ; 2 ; 7 ; 9 R4 ; 9 ; 7 ; 6 ; 1 R5 ; 5 ; 8 ; 1 ; 6 {csv}I get this message when I try it:
csv: Unexpected program error: java.util.regex.PatternSyntaxException: Unclosed character class near index 2 [ ^
In general I'm trying to figure out how to easily convert existing (giant) tables so that they are nicely sortable as in with CSV. Trying to set the delimiter has proven difficult for me.
I'd like to be able to just set the delimiter to be "|" if I could — this would reduce the amount of edit/search/replace needed to convert old tables, and make it easier for people to add new content to this type of table (no accidental piping when tired).
It would be very nice if we could just wrap existing tables in this (or another) macro to make them sortable.
Apr 06, 2006
Bob Swift says:
The regular expression option had to be removed some time ago in order to accura...The regular expression option had to be removed some time ago in order to accurately support the pseudo-csv standard. The notation guide was updated, but, I see this page was not
. I will correct that. The following will work. Note that you need a space before a new line starting with the delimiter.
{csv:delimiter=;} ; Col 1 ; Col 2 ; Col 3 ; Col 4 R1 ; 1 ; 2 ; 3 ; 4 R2 ; 6 ; 4 ; 9 ; 2 R3 ; 8 ; 2 ; 7 ; 9 R4 ; 9 ; 7 ; 6 ; 1 R5 ; 5 ; 8 ; 1 ; 6 {csv}Apr 06, 2006
Bob Swift says:
And to answer your other question, "|" doesn't work since it gets stripped out ...And to answer your other question, "|" doesn't work since it gets stripped out being a macro parameter divider. I can support a delimiter=pipe easily enough. Create an issue (see top of page) for me please.
Apr 07, 2006
Russell Warren says:
An issue has been raised: http://developer.atlassian.com/jira/browse/SCRP-64An issue has been raised: http://developer.atlassian.com/jira/browse/SCRP-64
Aug 17, 2006
Osma Ahvenlampi says:
The Excel macro supports reading the table out of a file or a url, whereas this ...The Excel macro supports reading the table out of a file or a url, whereas this csv macro supports only content stored within confluence. I'd like to be able to use it to render output generated by another server as a php script. It'd be easy to output csv there, but I can't read it in with the macro. Any suggestions?
Aug 17, 2006
Bob Swift says:
CSV macro has the script parameter which allows for access to a file on the serv...CSV macro has the script parameter which allows for access to a file on the server. I guess you are probably asking about URL support, which is missing at the moment. That can and should be included in the next release. Please write up an issue so it doesn't get forgotten at http://developer.atlassian.com/jira/browse/SCRP
Jan 28, 2008
ria ninan says:
I have to display the data in a .csv file on a page..There are about 30 rows in ...I have to display the data in a .csv file on a page..There are about 30 rows in that file..Now I have a requirement that at a time only few should be displayed..The remaining are to be displayed on clicking some icon(show more)..
Can you please suggest the best way to accomplish this task? Looking forward for any suggestions...
Jan 28, 2008
Bob Swift says:
Row selection is not currently supported. Please create an issue for your requi...Row selection is not currently supported. Please create an issue for your requirement.
Jan 28, 2008
ria ninan says:
Thank you Bob...I shall soon create an issue for the requirementThank you Bob...I shall soon create an issue for the requirement
Jul 04
arun.gangadharan says:
Hi Bob, I have a csv file and I want to display it in wiki page by giving...Hi Bob,
I have a csv file and I want to display it in wiki page by giving the location of csv file. What is the command used to accomplish this task?
Looking forward for your reply..
Jul 04
Bob Swift says:
Look at the script parameter for more details. Here is an example with an atta...Look at the script parameter for more details. Here is an example with an attachment.
{csv:script=^myAttachment.csv} {csv}Jul 04
arun.gangadharan says:
Thank you Bob..Thank you Bob..