It's all about the answers!

Ask a question

How can I import a tab-separated CSV using Workitem-command-Line?


HIROAKI JOSAKO (47427) | asked Sep 16 '22, 4:51 a.m.
edited Sep 19 '22, 8:12 p.m.

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<


Comments
Ralph Schoon commented Sep 16 '22, 6:50 a.m. | edited Sep 16 '22, 6:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 How did you call WCL? Did you try the -delimiter parameter?


David Honey commented Sep 16 '22, 10:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You might want to consider converting the tab separated value file into a comma separated value file and use that instead.


HIROAKI JOSAKO commented 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"

Accepted answer


permanent link
Ralph Schoon (63.1k33645) | 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



permanent link
HIROAKI JOSAKO (47427) | answered Sep 20 '22, 1:31 a.m.

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
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.  

I have added special treatment that allows to pass "\t" to WCL.


HIROAKI JOSAKO commented Sep 26 '22, 3:49 a.m. | edited Sep 26 '22, 3:58 a.m.

 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.


permanent link
Ralph Schoon (63.1k33645) | 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
Ralph Schoon commented Sep 16 '22, 8:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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!
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


Ralph Schoon commented Sep 20 '22, 2:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The code of WCL never supported \t as delimiter correctly. So a code change was needed. 

Your answer


Register or to post your answer.