Tool for converting CSV file to JIRA/Wiki table format in SublimeText 2. This is a Sublime Text 2 plugin.
CSV2JIRATable is a plugin for Sublime Text 2 that allows you to convert CSV formatted data to JIRA formatted table.
Go to your Packages
subdirectory under ST2's data directory:
- Windows:
%APPDATA%\Sublime Text 2
- OS X:
~/Library/Application Support/Sublime Text 2/Packages
- Linux:
~/.config/sublime-text-2
- Portable Installation:
Sublime Text 2/Data
Then clone this repository:
git clone git://github.com/mkolodziejski/CSV2JIRATable-ST2.git
That's it!
Current version assumes, that there is a header in first row of processed data, and formats it differently (using "header_separator" from settings as a separator character). If Your data don't have a header, just replace it by yourself, or change "header_separator" to the same value as "column_separator".
Many applications (JIRA, Confluence, etc.) have input format for tables as defined in markup specification. But applications that process data, are assuming (correctly!) that the standard format is CSV Comma Separated Values, and JIRA and other applications does not accept such data format.
A,B,C
1,2,3
4,5,6
A | B | C |
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
To achive this, the CSV format data have to be converted to JIRA format.
||A||B||C||
|1|2|3|
|4|5|6|
After opening the CSV file in Sublime Text 2, it is now possible to convert to JIRA format
. There are two possibilities:
- using a shortcut
ctrl+alt+j
- using a context menu: (rightclick) on opened file
CSV2JIRA -> Convert & Copy
This plugin copies converted text to clipboard
Some options are available to customize the plugin behaviour. The config keys goes into config files accessible throught the "Preferences" menu.
{
"normalize_line_endings" : true,
"delete_blank_lines" : true,
"national_characters" : "xmlcharrefreplace",
"default_line_ending" : "\n",
"column_separator" : "|",
"header_separator" : "||"
}
This setting determines what character (or string) is to be used to separate columns in output.
{
"column_separator" : "|"
}
This setting determines what character (or string) is to be used to separate HEADER columns in output.
{
"header_separator" : "||"
}
This setting determines what to do with a "national characters" which are outside ASCII range.
{
"national_characters" : "xmlcharrefreplace"
}
Value | Description |
---|---|
'ignore' | removes the national characters |
'replace' | replaces with ? |
'xmlcharrefreplace' | turn into xml entities |
'strict' | will throw UnicodeEncodeErrors if found any non-unicode character |
This setting determines if line endings should be normalized.
{
"normalize_line_endings" : true
}
Algorithm
- Take the text
- replace "\r\n" with "\n"
- replace "\r" with "\n" <- now we have all the endings as "\n".
- replace "\n" with desired line ending (based on system settings)
Type (standard) | Normalized value |
---|---|
windows | '\r\n' |
mac | '\r' |
This setting determines if "blank" (empty) lines shoul be ignored or processed. As blank line is considered to have consecutive line endings).
{
"delete_blank_lines" : true
}
Type (standard) | Input value | Output value |
---|---|---|
windows | '\r\n\r\n' | '\r\n' |
mac | '\r\r' | '\r' |
unix | '\n\n' | '\n' |
This setting determines what character should be used to end a line in output.
{
"default_line_ending" : "\n"
}
This setting determines added input_separator parameter to chose which character to treat as separator while parsing input lines.
{
"input_separator" : "\t"
}
This setting determines if plugin should process a whole file (when set to "false") or only the selected text in view (when set to "true")
{
"process_only_selection" : true
}
Special thanks to Max Shawabkeh for his REGEXP (http://stackoverflow.com/questions/2212933/python-regex-for-reading-csv-like-rows)
It all started by 'scratching own itch' - plugin created solely for my own consumption. Then I've decided to share it with ST2 users-community.
2013-12-31
- Initial version.
2014-02-12
- Fixed issue #1 #1
2014-02-14
- added parameter "input_separator" to set separator character/string for columns in input text
2014-02-27
- added parameter "process_only_selection" to determine if plugin should process a whole file (when set to "false") or only the selected text in view (when set to "true") (Fixed issue #2 #2)