delimiter

CSV writing strings of text that need a unique delimiter

点点圈 提交于 2019-12-02 08:53:35
问题 I wrote an HTML parser in python used to extract data to look like this in a csv file: itemA, itemB, itemC, Sentence that might contain commas, or colons: like this,\n so I used a delmiter ":::::" thinking that it wouldn't be mined in the data itemA, itemB, itemC, ::::: Sentence that might contain commas, or colons: like this,::::\n This works for most of the thousands of lines, however, apparently a colon : offset this when I imported the csv in Calc. My question is, what is the best or a

StringTokenizer delimiters for each Character

泄露秘密 提交于 2019-12-02 08:06:10
I've got a string that I'm supposed to use StringTokenizer on for a course. I've got my plan on how to implement the project, but I cannot find any reference as to how I will make the delimiter each character. Basically, a String such as "Hippo Campus is a party place" I need to divide into tokens for each character and then compare them to a set of values and swap out a particular one with another. I know how to do everything else, but what the delimiter would be for separating each character? If you really want to use StringTokenizer you could use like below String myStr = "Hippo Campus is a

Java Scanner Delimiter Usage

我只是一个虾纸丫 提交于 2019-12-02 07:52:33
问题 I'd like to specify a delimiter for a scanner that splits on some pattern, but doesn't remove that pattern from the tokens. I can't seem to make this work, as anything that is identified by the regex also gets eaten as part of the delimiter. Any suggestions? My specific problem, I have file that looks like: text/numbers mix numbers numbers text/numbers mix numbers numbers numbers . . I'd like to split out from the text/numbers mix+rows until the next text/numbers mix. I have the regex to

java string delimiter, keeping delimiter in token

六月ゝ 毕业季﹏ 提交于 2019-12-02 07:11:46
问题 im trying to split a string but keep the delimiter at the beginning of the next token (if thats possible) Example: I'm trying to split the string F120LF120L into F120 L F120 L I've tried StringTokenizer st = new StringTokenizer(str, "F,L"); but that just returns 120 120 回答1: From the docs, you can use StringTokenizer st = new StringTokenizer(str, "L", true); The last parameter is a boolean that specifies that delimiters have to be returned too. 回答2: Use split(), for all practical purposes

Splitting up data file in Java Scanner

六月ゝ 毕业季﹏ 提交于 2019-12-02 06:04:07
问题 I have the following data which I want to split up. (1,167,2,'LT2A',45,'Weekly','1,2,3,4,5,6,7,8,9,10,11,12,13'), to obtain each of the values: 1 167 2 'LT2A' 45 'Weekly' '1,2,3,4,5,6,7,8,9,10,11,12,13' I am using the Scanner class to do that and with , as the delimiter. But I face problems due to the last string: ('1,2,3,4,5,6,7,8,9,10,11,12,13') . I would hence like some suggestions on how I could split this data. I have also tried using ,' as the delimiter but the string contains data

Using the asterisk-character as a Java Scanner Delimiter

こ雲淡風輕ζ 提交于 2019-12-02 05:55:22
问题 Hey Everyone, This question seems really silly to me, but I can't for the life of me find the answer anywhere. All I'm trying to do, is scan a string that is delimited with an asterisk (* ). However, when I try foo.useDelimiter("*");, Java interprets the asterisk as a wildcard, and uses EVERY character as a delimiter... This is obviously not what I want. I've tried using a backslash as an escape character, but that gives me the compiler error "illegal escape character". This is probably very

BASH SHELL: Using awk, with a delimiter, 2 search terms

一曲冷凌霜 提交于 2019-12-02 05:41:59
I'm very new to BASH Shell programming. Here's my issue, I need to split data from my file (with a semicolon delimiter) and search if a certain book exists. file contents: Harry Potter - The Half Blood Prince:J.K Rowling:40.30:10:50 The little Red Riding Hood:Dan Lin:40.80:20:10 Harry Potter - The Phoniex:J.K Rowling:50.00:30:20 Harry Potter - The Deathly Hollow:Dan Lin:55.00:33:790 Little Prince:The Prince:15.00:188:9 Lord of The Ring:Johnny Dept:56.80:100:38 Three Little Pig:Andrew Lim:89.10:290:189 All About Ubuntu:Ubuntu Team:76.00:55:133 Catch Me If You Can:Mary Ann:23.60:6:2 Happy Day

Split string based on regex but keep delimiters

感情迁移 提交于 2019-12-02 04:06:22
I'm trying to split a string using a variety of characters as delimiters and also keep those delimiters in their own array index. For example say I want to split the string: if (x>1) return x * fact(x-1); using '(', '>', ')', '*', '-', ';' and '\s' as delimiters. I want the output to be the following string array: {"if", "(", "x", ">", "1", ")", "return", "x", "*", "fact", "(", "x", "-", "1", ")", ";"} The regex I'm using so far is split("(?=(\\w+(?=[\\s\\+\\-\\*/<(<=)>(>=)(==)(!=)=;,\\.\"\\(\\)\\[\\]\\{\\}])))") which splits at each word character regardless of whether it is followed by one

R separate comma separated cells into rows and Cartesian product

跟風遠走 提交于 2019-12-02 03:57:16
I have mydf data frame below. I want to split any cell that contains comma separated data and put it into rows. I am looking for a data frame similar to y below. How could i do it efficiently in few steps? Currently i am using cSplit function on one column at a time. I tried cSplit(mydf, c("name","new"), ",", direction = "long") , but that didn`t work library(splitstackshape) mydf=data.frame(name = c("AB,BW","x,y,z"), AB = c('A','B'), new=c("1,2,3","4,5,6,7")) mydf x=cSplit(mydf, c("name"), ",", direction = "long") x y=cSplit(x, c("new"), ",", direction = "long") y There are times when a for

strtok() analogue in C++

元气小坏坏 提交于 2019-12-02 01:20:07
问题 I just can't find an algorithm to split the string into words by numerous delimiters. I know how to split a string by whitespace with istringtream and by single delimiter with getline . How can I connect them all. For instance: input : This -is-a!,string; output : This is a string 回答1: #include <iostream> #include <string> #include <vector> using namespace std; void SplitToVector(vector<string> &v, string dlm, string src){ string::size_type p, start=0, len=src.length(); v.clear(); start = src