Questions tagged [split]

Use this tag for questions about separating an item (e.g. a string) into parts, often by a delimiter or regular expression.

It is most often applied when splitting a string by a delimiter, such as when parsing a comma separated value file. Some languages such as Ruby and Java support splitting a string according to regular expression as well.

A split string produces an array of strings.

split can also refer to

  1. the split function
  2. the String#split method
  3. the str.split method
  4. the explode function.
  5. the split method
  6. the split method
  7. the // String.Split method
  8. the / split command line utility
  9. the STRING_SPLIT function

All these functions/methods split strings on a delimiter.

The split function in divides data into groups by a specified factor.

24261 questions
5
votes
5 answers

What is the difference between --split-by and --boundary-query in SQOOP?

Assuming we don't have a column where values are equally distributed, let's say we have a command like this: sqoop import \ ... --boundary-query "SELECT min(id), max(id) from some_table" --split-by id ... What's the point of using --boundary-query…
burakongun
  • 241
  • 4
  • 6
  • 17
5
votes
1 answer

Split string by comma but ignore commas in brackets or in quotes

I have a string like hello, "darkness, my", (old, friend) and I want this splitted result: hello "darkness, my" (old, friend) I found a way to ignore the commas in "-marks (,?=([^\"]*\"[^\"]*\")*[^\"]*$) and another way to ignore the commas in…
Selphiron
  • 897
  • 1
  • 12
  • 30
5
votes
4 answers

Java - regular expression to split directory paths

I am trying to do the following in Java give a directory path like "/a/b/c" I want to get a array of string as ["a", "b", "c"]. The code is as follows : private static final String DIRECTORY_PATH_SEPARATOR = "/"; Iterator iter =…
daydreamer
  • 87,243
  • 191
  • 450
  • 722
5
votes
2 answers

How to use CamelSplitIndex of outer split in inner split in Apache camel

I have to call a service for each element of an array B. but Array A is inside Array A. So I am trying to use split inside split as below in camel_Context.xml. Once the all inner split array value are executed, I need to aggregate them as…
Jay
  • 79
  • 2
  • 11
5
votes
3 answers

How does raw_input().strip().split() in Python work in this code?

Hopefully, the community might explain this better to me. Below is the objective, I am trying to make sense of this code given the objective. Objective: Initialize your list and read in the value of followed by lines of commands where each…
CTLearn
  • 115
  • 2
  • 3
  • 9
5
votes
2 answers

Why split() in R split matrix into vector and how can I get the matrix result?

I want to split a matrix into two parts. I used following code x <- matrix(rnorm(15),5,3) idx <- rbinom(5,1,0.5) split(x,idx) However, I got two vector instead two matrix. I know if I convert x to data.frame will get what I want. i.e. x <-…
David Lee
  • 107
  • 2
  • 7
5
votes
2 answers

Extract the nth to nth characters of an string object

I have a filename and I wish to extract two portions of this and add into variables so I can compare if they are the same. $name = FILE_20161012_054146_Import_5785_1234.xml So I want... $a = 5785 $b = 1234 if ($a = $b) { # do stuff } I have…
TOGEEK
  • 711
  • 4
  • 15
  • 34
5
votes
3 answers

Passing a boost::unordered_set as the result map to boost::split

Does anyone know if it's kosher to pass a boost::unordered_set as the first parameter to boost::split? Under libboost1.42-dev, this seems to cause problems. Here's a small example program that causes the problem, call it test-split.cc: #include…
5
votes
3 answers

R: how to split dataframe in foreach %dopar%

This is a very simple example. df = c("already ","miss you","haters","she's cool") df = data.frame(df) library(doParallel) cl = makeCluster(4) registerDoParallel(cl) foreach(i = df[1:4,1], .combine = rbind, .packages='tm') %dopar%…
M.T.
  • 51
  • 1
  • 3
5
votes
4 answers

R For loop fails applying max function

I premise I'm new with R and actually I'm trying to get the fundamentals. Currently I'm workin on a large dataframe (called "ppl") which I have to edit in order to filter some rows. Each row is included in a group and it is characterized by an…
AeonRed
  • 77
  • 6
5
votes
2 answers

Python: split list into indices based on consecutive identical values

If you could advice me how to write the script to split list by number of values I mean: my_list =[11,11,11,11,12,12,15,15,15,15,15,15,20,20,20] And there are 11-4,12-2,15-6,20-3 items. So in next list for exsample range(0:100) I have to split…
Protoss Reed
  • 265
  • 2
  • 6
  • 16
5
votes
1 answer

How to split a String in Java, ignoring multiple successive tokens

I'm trying to parse arguments for a command, but if I were to put multiple spaces in a row, String.split() will leave empty Strings in the result array. Is there a way I can get rid of this? For example: "abc 123".split(" ") results in {"abc",…
user322652
  • 85
  • 1
  • 4
5
votes
1 answer

How can I slice a dataframe by timestamp, when timestamp isn't classified as index?

How can I split my pandas dataframe by using the timestamp on it? I got the following prices when I call df30m: Timestamp Open High Low Close Volume 0 2016-05-01 19:30:00 449.80 450.13 449.80 449.90 74.1760 1…
dot.Py
  • 5,007
  • 5
  • 31
  • 52
5
votes
0 answers

FutureWarning: split() requires a non-empty pattern match

I am trying to split the sentences in "train_data" but it gives me an error: FutureWarning: split() requires a non-empty pattern match. Here is the code: #!/usr/bin/python # -*- coding: utf-8 -*- import re train_data = [ ("""What Are We…
Mitko Gurbanski
  • 105
  • 2
  • 4
  • 12
5
votes
1 answer

How to split a range into N parts

I am wondering how to split a range into N parts in ruby, While adding them to a hash with a zero based value for each range generated. For example: range = 1..60 p split(range, 4) #=> {1..15 => 0, 16..30 => 1, 31..45 => 2, 46..60 => 3} I've read…
randy newfield
  • 1,221
  • 3
  • 25
  • 38
1 2 3
99
100