How can I import a tab-separated CSV using Workitem-command-Line?
WCL 5.3.1
Plain-Javalib 6.0.6
JDK OpenJDK1.8.0
console:Windows CMD.exe(locale:japanese)
How can I import a CSV , delimiter use TAB?
"Delimiter Options do not set
No attributes or columns found for row 2. Check the import file format or delimiter. Delimiter is ';'
com.ibm.js.team.workitem.commandline.framework.WorkItemCommandLineException: Work item type not specified.
set option delimiter="\t"
Can not convert delimiter. Delimiter must have size 1 >\t<
Accepted answer
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.
2 other answers
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); }
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.
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.
thank you!
I will refer to the change idea.
It seems that some people respond without changing the program, so I will ask a question.
I will download sourcecode from master blanch
The code of WCL never supported \t as delimiter correctly. So a code change was needed.
I was confirmed.
It seems that "\t" was effective because OpenCSV was used in WCL4.0.
Consider changing the source code.
I think that comma "," is not used if possible because of risk.
Because there is a possibility of using a double coatation in the column.
Comments
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.
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.
I have added special treatment that allows to pass "\t" to WCL.
Thanks!!
*OpenCSV 4.3 not running `t.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Sep 16 '22, 6:51 a.m.How did you call WCL? Did you try the -delimiter parameter?
David Honey
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Sep 16 '22, 10:23 a.m.You might want to consider converting the tab separated value file into a comma separated value file and use that instead.
HIROAKI JOSAKO
Sep 19 '22, 10:22 p.m.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"