我希望标题有意义...

基本上我正在像这样阅读csv:

“空白”,“你好”,“ \”约翰,鲍勃”,“鲁迪,朱迪”,“某物”,“这里”

因此,理想情况下,我想将其存储到结果如下的数组中:

    // I'm going to use { } to separate the indexes so it'll be easier to read
    // each of these indexes will eventually be stored into their own array - they can contain multiple values
    // e.g like John, Bob and Rudy, Judy - they'll be in the same array but will be in index 0 and 1 and so on
    [{"blank"}, {"hello"}, {"John, Bob", "Rudy, Judy"}, {"something"}, {"here"}]


当我打印出数组的值时,应该是这样的:

    ...
    System.out.println(item)

    // results in:
    blank
    hello
    John, Bob
    Rudy, Judy
    ...


我的代码中有这样的内容:

    cand2 = (!csv2DArray[i][j].equals(" ")) ? csv2DArray[i][j].split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") : new String[0];
    System.out.print("Candidate2 for current contest is: ");
    for(String item: cand2) { System.out.println(item); }
    ...


但是当我打印出这些值时,我得到了这个:

    blank
    hello
    "John, Bob"
    "Rudy, Judy"
    ...


如何删除坚持在值的双引号?

这有意义吗?我基本上是在尝试比较值(Selenium UI测试)。因此,它将读取网站上的所有内容,将这些值存储在数组中,然后进行比较。

从UI中提取了什么

    ["John, Bob", "Rudy, Judy", ...]
    // when I check the debugger the values become
    John, Bob, Rudy, Judy...


我的代码产生了什么结果

    [""John, Bob"", ""Rudy, Judy"", ...]
    // when I check the debugger the values become
    "John, Bob", "Rudy, Judy", ...

最佳答案

尝试

for(String item: cand2) { System.out.println(item.replace ("\"", ""); }

关于java - 删除将csv中的值分组在一起的双引号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25799196/

10-12 00:02
查看更多