How can I import a tab-separated CSV using Workitem-command-Line?
WCL 5.3.1
|
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Sep 26 '22, 4:01 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER I do not know why apparently my answers are ignored. WCL DID NOT SUPPORT the TAB Character, regardless which OpenCSV version was used. The reason, the tab character is entered as a character that is longer than one character. That was prevented. I have added this capability in the newest code, but there is no release yet with the change. You would have to create your own release. Ralph Schoon selected this answer as the correct answer
Comments
HIROAKI JOSAKO
commented Sep 26 '22, 4:24 a.m.
I'm sorry, I didn't intend to ignore it.
I understand that it is not supported.
I am trying to change "corresponding to \t".
|
2 other answers
Ralph Schoon (63.5k●3●36●46)
| answered Sep 16 '22, 6:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER The answer is: I do not know how you could specify a tab as the character <tab> passing "\t" does not work, because it has more than one character. It would be necessary to enhance the tool to be able to provide a way to specify tab as a string input. The source is available on Github, if you have the time, I would be happy about suggestions or a pull request.. Comments This is the code that would need to change. It basically converts the char from the string and can not handle quote characters. This would need to change. /* * setter for the quote character * * @return / private void setDelimiter(String delimiter) { if (delimiter.length() != 1) { throw new WorkItemCommandLineException("Can not convert delimiter. Delimiter must have size 1 >" + delimiter + "<"); } fDelimiter = delimiter.charAt(0); }
Ralph Schoon
commented Sep 16 '22, 9:36 a.m.
| edited Sep 19 '22, 2:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
This is not an easy feat and I found that a lot of claims how to do this e.g. on stackoverflow did not work.
The code below should work but I have no time to test it.:
The problem is, that the escaped character in the command line is converted to a string with two backslashes and a t like "//t" (replace the slash with a backslash, the forum does not display both backslashes....).
Ralph Schoon
commented Sep 16 '22, 10:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I did the required changes and delivered to the master. However, I do not have the time to test (I only tested export which works) and I can not create a release.
HIROAKI JOSAKO
commented Sep 19 '22, 10:49 p.m.
thank you!
The code of WCL never supported \t as delimiter correctly. So a code change was needed. |
I was confirmed.
Comments
David Honey
commented Sep 20 '22, 11:35 a.m.
| edited Sep 20 '22, 11:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
CSV files with values that contain commas should be safe. The correct encoding is to enclose the value in double quotes, with any quotes in the value being escaped. There are standard Java libraries, such as OpenCSV, that take care of issues like this.
Ralph Schoon
commented Sep 23 '22, 4:52 a.m.
| edited Sep 23 '22, 4:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
No, your version of WCL has a specific rule implemented that prevents to enter tab as "\t" regardless what library is used later. The way how "\t" is passed in the command line makes special handling necessary, which required code changes. I have detailed this in my various comments. I would suggest to use the , or ; as delimiter and use the quote characters '"' around the column values as David suggested.
Thanks!!
Even if the values enclosed in the double coatings contain a comma, if it is correctly recognized, a CSV using a comma may be fine.
example
id,summary,priority,owner
1234,"test id a,b,c or d",high,leader_bob
WCL ver4.0.0
At the time of this version, OpenCSV 3.7 was used,
It seems that `t can be used for Delimiter, only when running WCL with PowerShell.
*OpenCSV 4.3 not running `t. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
How did you call WCL? Did you try the -delimiter parameter?
You might want to consider converting the tab separated value file into a comma separated value file and use that instead.
I'm sorry for the late reply.
set delimiter's option
delimiter="\t"
CSV:
UTF-16le Divided character tab
command line
-importworkitems repository="https://rtc_ServerURL" user="user" password="password" projectArea="testproject" importFile="sample.csv" /importdebug encoding="UTF-16LE" delimiter="\t"