FAQ Database Discussion Community


Splitting single rows data into multiple rows

r,split,row
I have a set of data with co-authorships of 3k authors. I have columns with Sender and Receiver (or Source and Target) and a column with Journal name and Publication year. If some authors have more than one common article, the results gonna be comma-separated in one row. What I'm...

Extract last word from strings

split,google-spreadsheet,string-split
In Google Sheets I have string values in cells like so: 1 Gheringhap Street, Geelong VIC 3220, Australia I want to extract the country value from the string. The trouble is the string values have different numbers of commas so it's hard to say at which position the last value...

prolog misunderstanding. Split list into two list with even and odd positions. where is my mistake?

list,split,prolog
I'm trying to split a list into two other list. List Even with the elemnts in even possition and a List Odd with the others. I've been looking over iinternet a solution, but all seem to me like chinese, i can not understand the process. So this is what i've...

Split string between words and quotation marks

java,regex,split
I currently have this string: "display_name":"test","game":"test123" and I want to split the string so I can get the value test. I have looked all over the internet and tried some things, but I couldn't get it to work. I found that splitting using quotation marks could be done using this...

Java Read Text file with condition

java,split,bufferedreader
I'm just wondering if there's a way to read a text file and skip a line with specific string. For example (test1.txt): test0,orig,valid,nice test1,input,of,ol,[www] test2,[eee],oa,oq test3,wa,eee,string,int test4,asfd,eee,[tsddas],wwww Expected output : test0,orig,valid,nice test3,wa,eee,string,int I already have this code : String line; String test[]; try{ LineIterator it = FileUtils.lineIterator(file2,"UTF-8"); while(it.hasNext()){ line =...

Bash Find Gateway

arrays,bash,join,split
I'm not a bash expert at all. I'm trying to find my gateway by manipulating my found public IP and modifying the last byte: 205.207.123.138 -> 205.207.123.1 set to variable split variable on "." replace last entry with 1 array join Any advice appreciated. Cheers...

Split by a comma that is not inside parentheses, skipping anything inside them

java,regex,string,split
I know it might be another topic about regexes, but despite I searched it, I couldn't get the clear answer. So here is my problem- I have a string like this: {1,2,{3,{4},5},{5,6}} I'm removing the most outside parentheses (they are there from input, and I don't need them), so now...

R: how to split list into AM/PM

r,filter,split
The time stamp on the survey grouped all of my data into one column under StartTime, but I need to split my data into AM and PM groups. For example, right now my data looks like 8:37 PM 3:58 PM 10:22 AM 2:48 PM 6:33 PM 7:10 AM 10:59 AM...

javascript split or slice?

javascript,split,slice
I have a function that grabs the current user on my page. The variable currentUser equals the full name of the user. Sometimes that is just FirstName LastName but other times it is FirstName MiddleName LastName. I want to be able to split(or slice) currentUser by " " and set...

Escape / in .split()

javascript,regex,split
Need to escape / in javascript .split() function but cannot seem to figure out! input -> string "07777/25555,00255" or any of 0777/2555 0777,2555 output -> array {07777,25555,00255} var p = item.gdp.split(/ , | \//); Not really good with regex!...

How do i split text to a different column or remove a text from the original column?

excel,vba,excel-vba,text,split
I've copied a column of data starting from D9 to D-whatever, the copied data have both decimal value and text. The data varies in each cell in column D Example D9 : 1675.87 L/s D10 : 1555.87 L/s D11 : 1635.87 L/s This is my code i tried.. Dim c...

How to split data monthly in R

r,data,split
I have a dataset corresponding to the register of buys in a store, it is something like this: Date BuyId Price Description Category 2010-01-01 101028 100 ... ... 2010-01-01 101028 100 ... ... 2010-01-01 101028 100 ... ... 2010-01-01 101028 100 ... ... ... The dates in the dataframe goes...

Need a complex regular expression to split on camel case and numbers

php,regex,split,preg-split
I need to split on capital letters and numbers, with a series of capital letters getting split as an entire word anywhere in the string. It's probably easiest to just explain with examples, see the test script below: $tests = array('FooBar', 'fooBar', 'Foobar', 'FooBar1', 'FooBAR', 'FooBARBaz', '1fooBar', '1FooBar', 'FOOBar'); foreach($tests...

How to write regex for this javascript string

javascript,regex,split,string-split
How to write this string below "(22.0796251, 82.13914120000004),36", "(22.744108, 77.73696700000005),48",...and so on Like this: (22.0796251, 82.13914120000004) 36 (22.744108, 77.73696700000005) 48 ...and so on.................. .. How to do this using regex in javscript ? My try is this: substring = test.split(','); where test contains the data to be formatted. But its...

Split Python dictionary into multiple keys, dividing the values equaly

python,dictionary,split
I want to split a Python dictionary, dividing keys into multiple ones, whilst dividing the values of each key equally. Sample data: {'S-NSW-BAC-ENG': 15, 'S-NSW-BAC-FBE': 30} I want to convert to: {'H-NSW-BAC-ENG': 5, 'C-STD-B&M-SUM': 5, 'G-CAM-BAC-SUM': 5, 'H-NSW-BAC-FBE': 10, 'C-STD-B&M-SUM': 10, 'G-CAM-BAC-SUM': 10} My code so far: from openpyxl import...

R - How to split all the varaibles from a dataframe?

r,table,split
I have a table like: $V1 $V2 $V3 toto|380 peper|728A tomato|I765 toto|458 peper|798A ognion|L965 toto|3L0 ginger|2R8A lemon|I765 And I would like to split it by the "|" and finally get : $V1 $V2 $V3 toto peper tomato toto peper ognion toto ginger lemon I tried with: split(data, sep="|") but it's...

Split by a word (case insensitive)

python,regex,string,split
If I want to take "hi, my name is foo bar" and split it on "foo", and have that split be case insensitive (split on any of "foO", "FOO", "Foo", etc), what should I do? Keep in mind that although I would like to have the split be case insensitive,...

R split vector with jumps

r,vector,split
I have vector created with the following structure: full_seq <- runif(10^8) I want to generate a new vector, extracting samples of the same size. This works fine for me: full_splited <- split(full_seq, ceiling(seq_along(full_seq)/10^3)) Now, I need to jump from one to another chunk by a fixed size. Lets take a...

Regex match commas after a closing parentheses

javascript,regex,split
In Javascript, I am trying to split the following string var s1 = "(-infinity, -3],(-3,-2),[1,infinity)"; into an array ["(-infinity, -3]","(-3,-2)","[1,infinity)"] by using this statement s1.split(/(?=[\]\)]),/); to explain, I want to split the string by commas that follow a closing square bracket or parenthesis. I use the Look Ahead (?=[\]\)]), to...

Splitting a text line into separate lines from command line

text,split,command
What are some simple options to split a single text line into separate based on a character or pattern? I would like to do this from the command line. An example would be when you want to inspect the PATH. With a single simple command I'd like to split something...

Split a list into chunks determined by a separator

python,split
I have this list (python): [item1],[item2],[item3],[/],[item4],[item5],[item6],[/]...and so on. I want to separate these into chunks and the elements that will go into each chunk are the elements before the separator "/". So my chunks would look like: chunk1:[item1],[item2],[item3] chunk2:[item4],[item5],[item6] I've tried and tried, nothing efficient came to mind. Tried looping...

Split and Loop in java 8

java,split,java-8
I have this problem which I want to solve in java 8, I have a string which is concatenated by . A.B.C.D Number of characters in the string can vary. I have this method, which takes the string as input and number of level deep it has to go, I...

str_split adding empty elements in array end when reading from file

php,arrays,string,split
I found interesting problem while I was trying to achieve something simple like splitting string into array. The only difference here is that Im trying to take the string from .txt file My code is the following: $handle = fopen("input.txt", "r"); // open txt file $iter = fgets($handle); // here...

Word count not working when entering new line

c#,split,newline
I've been looking at other stack overflow articles regarding similar issues when it comes to word count in C#, but none have helped me when it comes to the pickle I've encountered. I have a textbox that inputs text from a text file. The text is split into three lines...

Splitting array in three different arrays of maximum three elements [duplicate]

arrays,ruby,split
This question already has an answer here: How to split (chunk) a Ruby array into parts of X elements? 2 answers I have an array: array = [12, 13, 14, 18, 17, 19, 30, 23] I need to split this array into arrays of maximum three elements each: [12,...

undefined method `split' for nil:NilClass Rails

ruby-on-rails,ruby,split
I am building a simple asset manager app in Rails 4.2.2 and Ruby 2.2.2. In my asset model I'm using a callback with before_create to call a function generate_asset_number like so def generate_asset_number company = "AMS" if Asset.count == 0 self.asset_number = "#{company}-00001" else last = Asset.last.asset_number end number =...

How is Guava Splitter.onPattern(..).split() different from String.split(..)?

java,regex,split,guava
I recently harnessed the power of a look-ahead regular expression to split a String: "abc8".split("(?=\\d)|\\W") If printed to the console this expression returns: [abc, 8] Very pleased with this result, I wanted to transfer this to Guava for further development, which looked like this: Splitter.onPattern("(?=\\d)|\\W").split("abc8") To my surprise the output...

How do I isolate the text between 2 delimiters on the left and 7 delimiters on the right in Python?

python,regex,string,split
I have a string: string = ""7807161604","Sat Jan 16 00:00:57 +0000 2010","Global focus begins tonight. Pretty interested to hear more about it.","Madison Alabama","al","17428434","81","51","Sun Nov 16 21:46:24 +0000 2008","243" I only want the text: "Global focus begins tonight. Pretty interested to hear more about it."" which is between the 2nd and...

Turn comma seperated string into an array [duplicate]

jquery,arrays,split,comma
This question already has an answer here: Convert comma separated string to array 9 answers I get a string like this from the my multi-select(link) assetmasterfields=$('#assetmaster').multipleSelect("getSelects"); var arr = assetmasterfields.split(','); console.log(arr) This syntax gives me error: 'assetmasterfields.split is not a function' I would like to turn this into a...

split string based on text qualifier regex java

java,regex,split
I want to split a string based on text qualifier for example "1","10411721","MikeTison","08/11/2009","21/11/2009","2800.00","002934538","051","New York","10411720-002",".\Images\b.jpg",".\RTF\b.rtf" Qualifer=" Spliter = , I want to split string based on Spliter , but if Spliter comes inside qualifier " than ignore it and return string including Spliter . Regular expression i am using is (?:|,)(\"(?:[^\"]+|\"\")*\"|[^,]*)...

Using split method to store values in HashMap

java,string,split,hashmap
I have a string in the following format : "(1,X) (3,2) (5,2) (7,2)" Basically the first element can be any positive integer, the second element is either '1' 'X' or '2'. The string can be of varying length with the minimum being one element. I want to split this string...

Complex string splitting

c#,regex,string,parsing,split
I have a string like the following: [Testing.User]|Info:([Testing.Info]|Name:([System.String]|Matt)|Age:([System.Int32]|21))|Description:([System.String]|This is some description) You can look at it as this tree: - [Testing.User] - Info - [Testing.Info] - Name - [System.String] - Matt - Age - [System.Int32] - 21 - Description - [System.String] - This is some description As you can see,...

Splitting Python List

list,python-2.7,split
I want to split the list below: my_list = [(55, 22), (66, 33), (77, 44)] I have tried: a, b = my_list This did not work. What I need is: a = [55,66,77] b = [22,33,44] I am looking for the simplest and easiest way....

Split the string from character and that character I don't want remove

javascript,regex,string,split
I want to split string in JS. I already know function str.split(); but I want something different. like: i have string var str = "Hello word" . i have to split these string from character o than string converted in array like : array = ['hell', 'o' , ' w',...

Return splitted value

java,regex,split,return-value
I'm having problems in splitting values in java. I have a string, and this must be split using the method .split(), but I need to return this value. For example I have this string: [#ff0000]red[#0000ff]blue Now I need you to return the value FF0000 for the red, and the value...

Split the strings into two parts Python

python,string,split
I'm trying to split a '/' connected string in one column and distribute them into two different columns. So what I have now in column 14 is AAA/BBB and I want to place AAA in column 2 and BBB in column 3. 1 2 3 4 5 6 AAA BBB...

HTML help for mouseover split button image

image,split,mouseover
I am a neophyte at HTML as my question may reflect, but I could use some help. I have a table cell that contains what looks line one button but is actually two side by side. My goal is when the one on the left is hovered over in the...

Splitting a floating point number into a sum of two other numbers, without rounding errors

split,floating-point,floating-accuracy
I don't know if it is possible to do this, but i need to split a floating point number in sum of two number... For example assuming x is a floating point number and we want to split this in x = I + f, where I is the signed...

Splitting a delimited file and storing into new column

python,split
I am trying to split csv file. After reading the delimited file, I want to split desired column furthur. My sample code: import csv sample = open('~/sample.txt') adr = csv.reader(sample, delimiter='|') for row in adr: a = row[0] b = row[1] c = row[2] d = row [3] new="" new...

Split string using word but keep the word in each array index

java,regex,string,split
The following code, String string = "<xml attributes>some xml code</xml>" + "<xml attributes>some xml code</xml>" + "<xml attributes>some xml code</xml>" + "<xml attributes>some xml code</xml>"; String[] stringArray = string.split("<xml"); for ( String i : stringArray) { System.out.println(i); } Prints attributes>some xml code</xml> attributes>some xml code</xml> attributes>some xml code</xml> attributes>some xml...

Powershell For Loop, Replace, Split, Regex Matches

regex,powershell,replace,split
$i=0;$pnp = pnputil -e; $matched = [regex]::matches($pnp, ".......................................Lexmark International"); $split = $matched -split (".........inf"); $replace = $split -replace " Driver package provider : Lexmark International",""; $replace1 = $replace -replace " ","`n";write-output $replace1; foreach ($i in $replace1){;$pnpdel = pnputil -f -d $i;$pnpdel;}; Reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\Lexmark Universal v2 XL" /f; net...

Excel VBA Macro to get the substring of text before semicolon

excel,vba,excel-vba,split,substring
I have working code here. In section (3) it grabs values from a cell under a specific header and prints them to a masterfile. These values typically look like TL-18273982; 10MM TL-288762; 76DK CT-576 N/A I would like to grab just the information that is before the first semicolon. Not...

Creating new columns by splitting a variable into many variables (in R)

r,string,split,data.frame
I want to create new columns by splitting a vector in a data frame. I have such a data frame: YEAR Variable1 Variable2 2009 000000 00000001 2010 000000 00000001 2011 000000 00000001 2009 000000 00000002 2010 000000 00000002 2009 000000 00000003 ... 2009 100000 10000001 2010 100000 10000001 ... 2009...

Python Split files into multiple smaller files

python,file,split
Write a function named file_split(filename, number_of_files) that will split an input file into a number of output files. The files should be split as evenly as possible. When the file length is evenly divisible by the number of files to create (a 10-line file, split into 2 files, each output...

TypeError when split converting string to integer

python,string,split,integer,type-conversion
I get to read a line from a file that contain certain set of numbers per line. My problem is that the input is from a string line and then I need to process it as integer, making the conversion as usually suggested. Although I check previous post on this...

MySQL split a column out with ID

mysql,table,split
I'm looking to split one of my MySQL columns out as it is made of words separated via , (commas). I need to split the data on the (,) and also collect the corresponding ID so I can place it into anther table. What the easiest way to go about...

Splitting a document from a tm Corpus into multiple documents

regex,r,split,tm,text-analysis
A bit of a bizarre question, is there a way to split corpus documents that have been imported using the Corpus function in tm into multiple documents that can then be reread in my Corpus as separate documents? For example if I used inspect(documents[1]) and had something like `<<VCorpus (documents:...

python splitting string twice

python,string,split,pair
i'm trying to split a string twice with the goal of converting a>b where b contains numbers and is split into multiple x/y pairs a = '{1;5}{2;7}{3;9}{4;8}' b = [[1,5],[2,7],[3,9],[4,8]] my code is currently this... b = a.split('}{') for item in b: item.replace('{','') item.replace('}','') item.split(';') the first split works correctly...

java: does the string .split method change the size of an array

java,string,split
So I initialized an array lets say `string example = new string [5]; When I called the split method on a line of string x = "abc, def, g"; example = x.split(","); example[0] = abc example[1] = def example[2] = g I can no longer access example[3] and example[4] as...

Talend JSON structure

json,mongodb,split,tree,talend
I am struggling with my mongodboutput because I can't figure out how to build my JSON tree. Basically I have this in the "Languages" attribute of my row: Languages##English##fluent##German##beginner## I would like to have : "languages": [ { "language": "English", "level": "fluent" }, { "language": "German", "level": "beginner" } ]...

Split rows that have multiline text and single line text

excel,vba,excel-vba,split
I'm trying to figure out how to split rows of data where columns B,C,D in the row contain multiple lines and others do not. I've figured out how to split the multi-line cells if I copy just those columns into a new sheet, manually insert rows, and then run the...

How to parse/split a string?

java,string,parsing,split
This is my string which is returned from DB, "N,591;F\"Vendor Number\",86;F\"Vendor Name\",143;F\"Claim Number\",82;" and stored in string columns, I want to extract 'Vendor Number','Vendor Name' and 'Claim Number'..Any ideas how I can do that? Thanks......

split signal right before local minima in Numpy

numpy,split
consider the following numpy array named final1 (signal): I would like to separate the previous array into 4 sub arrays. The four sub arrays are separated by the moment right before the local minima, as shown in the following image: The idea I have is to find the local minima...

Python, splitting strings on middle characters with overlapping matches using regex

python,regex,split
In Python, I am using regular expressions to retrieve strings from a dictionary which show a specific pattern, such as having some repetitions of characters than a specific character and another repetitive part (e.g. ^(\w{0,2})o(\w{0,2})$). This works as expected, but now I'd like to split the string in two substrings...

Split a text file according to data into multiple files in Unix

unix,split
Assume the input file is sorted according to column 3 (the barcode begins with "TCGA"): Joe 1 TCGA-A8-A08L-01A-11W-A019-09 T John 2 TCGA-A8-A08L-01A-11W-A019-09 T Jack 3 TCGA-A8-CVDL-01A-11W-A019-09 T Jane 4 TCGA-A8-CVDL-01A-11W-A019-09 F Justin 5 TCGA-A8-E08L-01A-11W-A019-09 F Jasmine 6 TCGA-A8-E08L-01A-11W-A019-09 T Jacob 7 TCGA-A8-E08L-01A-11W-A019-09 T I want to split this text into...

Split string in AWK using multi-character delimiter

bash,awk,split
I have the following delimiter and string: DEL=":::" STR="info1"$DEL"info2"$DEL"info3" I want to extract info1-2-3 from STR using awk. The following works: info1=$(echo $STR | awk '{split($0,a,":::")} END{print a[1]}') info2=$(echo $STR | awk '{split($0,a,":::")} END{print a[2]}') info3=$(echo $STR | awk '{split($0,a,":::")} END{print a[3]}') The following does NOT work: info1=$(echo $STR |...

Splitting a text file

python,text,split
I have a folder with a set of text documents. I want to split each document to two or three documents, each one should be 45-70kb. How сan I do it? I tried: def split_file(filename, pattern, size): with open(filename, 'rb') as f: for index, line in enumerate(f, start=1): with open(pattern.format(index),...

raw_input multiple inputs around strings

python,split,raw-input
Is it possible for the user to input multiple variables around strings (so they are there as they type). I want the user to input numbers x,y,u,v like (x,y) to (u,v) where the brackets and commas are there to guide their input. I hope it to be something (I know...

String split after a number and symbol

java,string,split
I have a sample string eg "ZZZ-1234567890-from ABC-2 DEF" I need the output to be: "from ABC-2 DEF" All the sample strings are in the format "ZZZ-numbers-Strings" I need to get the string part after "ZZZ-numbers-" I tried using split() but could not solve it. Appreciate the help!...

In a MySQL select statement, can I split a text column and then sum the parts as floats?

mysql,select,casting,split
I have a MySQL column that is defined as text. The column, if not null, always contains a list floats separated by a newline character. I have been tasked with making the total amount of those floats searchable with min and max constraints. In the where clause, I would like...

How can I populate comboboxes from arrays?

c#,arrays,wpf,combobox,split
I a text file with names and phone numbers. My lecturer gave me a piece of code to split this into two arrays. Now I'm having trouble populating the name and phone number comboboxes with these arrays. All I get is errors saying array1 and array2 don't exist in the...

Apache Hadoop pig SPLIT not working. Giving Error 1200

hadoop,split,apache-pig,latin
Structure of bag: emp = LOAD '...../emp.csv' using PigStorage(',') AS (ename:chararray,id:int,job:chararray,sal:double) This bag contains details of employees. I want to split the data based on job. Bag = split emp into mngr if job == 'MANAGER'; This is not working & giving Error 1200. If I include one more condition...

PHP split or explode string on tag

php,regex,split,html-parsing,explode
i would like to split a string on a tag into different parts. $string = 'Text <img src="hello.png" /> other text.'; The next function doesnt work yet on the right way. $array = preg_split('/<img .*>/i', $string); The output should be array( 0 => 'Text ', 1 => '<img src="hello.png" />',...

Merging text files based on headings.

c#,visual-studio-2010,visual-studio,visual-studio-2012,split
I am looking for some advice on how I could merge multiple text files based on their headings. So say I have the following 3 text files with the following headings. As you can see some elements repeat and some are unique to the text file. The text files contain...

python: splitting strings where numbers and letters meet (1234abcd-->1234, abcd)

python,string,list,split
I have a string composed of numbers and letters: string = 'this1234is5678it', and I would like the string.split() output to give me a list like ['this', '1234', 'is', '5678', 'it'], splitting at where numbers and letter meet. Is there an easy way to do this?

perl split to grab time in the string

perl,split
Current we have a shared software, the purpose of the script is to collect all the using time for each user. To do this, I want to find the log file by user and grab the rows which record the running time and add it up to a final number...

How to keep punctuation as a separate element in split_string in Prolog

string,split,prolog,swi-prolog,punctuation
I'm doing an assignment in Prolog (I'm a newbie) and I have a small problem. I know you can split a string to a list of elements in Prolog like this: split_string("Hello, here I am!"," "," .!?-_'",Temp). But this takes out the basic punctuation. It returns: Temp = ['Hello','here','I','am']. How...

How to use Split() method in Android

java,android,string,list,split
I have String like this. ex:- String myString = "A=myPage{a1,b1,c1};B=myPage{a2,b2,c2};C=myPage{a3,b3,c3};" I need to put each {_,_,_} part into List. like: If List<String> list = new ArrayList() then, list[0]="a1,b1,c1", list[1]="a2,b2,c2", list[2]="a3,b3,c3" I tried to use split, but I don't know how to apply it into this for getting my result. for...

Python Split Array use For Loop to Mean every split and put it back together

python,arrays,for-loop,split
I'm coding for an Coherence project and I'm now stuck at the problem to mean my array of values in splitted parts. So ym task would be: 1. Take my array of values (R) split it in a certain number of array parts (split by epoch) 2. enter a loop...

split string in uppercase and camel case halves

regex,string,split
I have a set of strings in the form "UPPERCASE STRING Normal string". The uppercase part is made of different number of words (from 1 to 3), the second part sometime is absent. I am trying to separate those strings in two (es "UPPERCASE STRING" "Normal string") but I am...

Code need to split string AND remove unwanted characters

c#,asp.net,string,split,string-split
I have a page which receives a list of dates in the following format via ajax: ["2015-06-02T23:00:00.000Z","2015-06-03T23:00:00.000Z","2015-06-04T23:00:00.000Z","2015-06-05T23:00:00.000Z"] I have written the following code to split the dates out: string input; using(var reader = new StreamReader(Request.InputStream)){ input = reader.ReadToEnd(); } string [] arr = input.Split(new string[] {","},StringSplitOptions.None); but i need to...

In R: get multiple rows by splitting a column using tidyr and reshape2

r,split,reshape2,tidyr
What is the most simpel way using tidyr or reshape2 to turn this data: data <- data.frame( A=c(1,2,3), B=c("b,g","g","b,g,q")) Into (e.g. make a row for each comma separated value in variable B): A B 1 1 b 2 1 g 3 2 g 4 3 b 5 3 g 6...

Display first Word in String with Ruby

ruby-on-rails,ruby,ruby-on-rails-4,split,string-split
I'm using ruby on rails and I want to display only first word of string my broken code <%= @user.name %> displaying Barack Obama I would want to have it display Barack and in other place Obama. How can I split it and display it? Thanks...

How to split string on multiple delimiters keeping some delimiters?

php,regex,string,split,explode
i'm looking for a way to split a string in several words, based on some delimiters. For example the string word1&word2 !word3 word4 &word5 should give me an array with the following words: word1 &word2 !word3 word4 &word5 How to reach that? I tried several solution with str_replace() but i...

hadoop large file does not split

performance,hadoop,split,mapreduce
I have an input file of size 136MB and I launched some WordCount test and I monitor only one mapper. Then I set dfs.blocksize to 64MB in my hdfs-site.xml and I still get one mapper. Am I doing wrong ?

Regex to split string by whitespace OR minus signs in C#

regex,string,split
I have a string with a list of temperatures that can be in the negatives or positives. Some of these temperatures will be separated by a whitespace, while some won't be. i.e.: 19 20 22 -1 -3-4-10 -7 2 10 And I want to split that string by keeping only...

Convert timestamp in HH:TT:SS format to seconds

python,python-2.7,split,timedelta,python-datetime
I'm trying to create a code on py2.7 to calculate the time difference for the time format of HH:MM:SS and convert it to seconds. Turns out I had to call seconds like so: timediff = a-b seconds = timediff.total_seconds() #This was the simple solution The error I did receive was:...

how to split a number without losing other same characters in Java

java,regex,split
I was using Eclipse for Java and I want to split a number without losing other same characters. For example, the input line is: [1142,143,2142,142] the output should be like that: 1142 143 2142 i was using split("142|\\D+")but the output was showing like this: 1 143 2 What should...

C# IEnumerable and string[]

c#,arrays,string,split,ienumerable
i searched for a method to split strings and i found one. Now my problem is that i can´t use the method like it is described. Stackoverflow answer It is going to tell that i cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'string[]'. The provided method is: public static class EnumerableEx...

Split CSV with a regex

regex,csv,split
I would like to have a CSV parser. However, I would like to have the following: the regex must check, that the CSV ends with a comma , (otherwise the regex must not consider the CSV as valid)! If CSV is OK, then I will extract the text between ,....

Python - Split string of numeric values with unknown delimiters

python,regex,string,split
I need to parse the numeric values from a string that is not well formatted. Example: "0 0 .1 .05 .05 0. 0. .01" or "0,0,.1,.05,.05,0.,0.,.01" As you can see the delimiter can vary from several spaces to commas with no spaces. Also, the numbers may be ints or floats....

Powershell Split a file name

powershell,split,get-childitem
I have to copy the files of diferent directories in their directory changing their name. I have some problems with the command split. The variable $nom contains all the files in a directory: example: a.out b.out c.out Then I want to cut the first word. "a" -> a.out But when...

Scala: Convert a csv string to Array

arrays,string,scala,split,scala-collections
I tried to convert a scala string to array by splitting it by ,.For example: var string = "a,b,c,d," array = string.split(",") arr: Array[String] = Array(a, b, c, d) But the output I am getting is Array(a, b, c, d), instead of Array(a, b, c, d, ). The last comma...

Compare one string among multiple values in another string [closed]

java,regex,string,split,compare
I have 2 string as following. In first_string="B" and in second_string="A,B,C,D,E". How do i compare first_string against individual value of second_string?...

How to split a table in 4 groups?

sql,sql-server,split
I have a table with two columns. The Seq column goes from 1 to 100. Part_No Seq A23 1 B88 2 C34 3 A43 4 B48 5 E11 6 A87 7 E64 8 ...TILL Seq 100 I now want to split this table like below: Part_No_a Part No_b Part_No_c Part_No_d...

Split Variable and insert NA's in between

r,variables,split,data.frame
I have a variable which looks like this: Var [1] 3, 4, 5 2, 4, 5 2, 4 1, 4, 5 I need to split it into a dataframe which looks like this: V1 V2 V3 V4 V5 NA NA 3 4 5 NA 2 NA 4 5 NA 2...

Count the number of consecutive pairs in a vector

r,table,count,split,categories
Suppose that I have the following vector: V<-c(-1,-1,-1,-1,-1,-1,-1,-1,1,1) and I want to count the number of CONSECUTIVE pairs in the following categories: (1,1), (-1,1), (1,-1), and (-1,-1). In my example, there are seven consecutive pairs of (-1,-1), one pair of (-1,1), and 1 pair of (1,1). I am trying to...

Python - Splitting a large string by number of delimiter occurrences

python,string,split
I'm still learning Python, and I have a question I haven't been able to solve. I have a very long string (millions of lines long) which I would like to be split into a smaller string length based on a specified number of occurrences of a delimeter. For instance: ABCDEF...

Create an array-of-arrays from an array's elements

php,arrays,split
I'm looking for a function to take a simple array and create an array of arrays, without iterating through the original array (i.e., foreach) For example, give this array: ['a','b','c','d'] I want the result to be: [['a'], ['b'], ['c'], ['d']] Does such a function exist?...

How can I recreate a list of list of floats from the contents of a file?

python,string,list,text,split
I have a text file coords.txt containing lists in separated rows: [0, 0.0, 0.0] [0, 2.0, 1.0] [0, 1.0, 4.0] the first column is ID, second and third ones - coordinates. I want to obtain following effect: [[0, 0.0, 0.0], [0, 2.0, 1.0], [0, 1.0, 4.0]] I try the code:...

Split Cell by Numbers Within Cell

excel,vba,split,cells
I have some fields that need to be split up into different cells. They are in the following format: Numbers on Mission 21 0 21 Numbers on Mission 5 1 6 The desired output would be 4 separate cells. The first would contain the words in the string "Numbers on...

Split a string only by first space in python

python,string,split
I have string for example: "238 NEO Sports". I want to split this string only for the first space. The output should be ["238","NEO Sports"]. One way I could think to this is by split() and adding the other two. Is their any other way to do so?

How to extract specfic data from lines in a text file and output to a new text file using C#

c#,regex,split
I have several large .csv files that contain lines of data. I need to extract from each line only specific parts of the data, thereby ignoring the parts I am not interested in and output the result into a new text file. For example, here is a section of the...

Split string in macro

c++,string,split,macros
I've a class name with its namespace, like BasicType::MyType. It's possible to create a macro that split the name and uses only the part after the scope operator (I want to create a MyType object in macro without the first part)? EDIT: I'm using a library with different classes in...

SPLIT using “ ” delimiter in Google Sheets won't always preserve period following number

regex,string,split,google-spreadsheet,string-split
I'm using the SPLIT function to divide text around white spaces (" ") in strings. However, the output is inconsistent when a number is immediately followed by a period. Column A below contains strings, and column B the function =SPLIT(A1," ") copied down: Note how cell B1 does not contain...

re.split return None in function but normaly works OK

python,python-3.x,split
def whois(k, i): k = str(k[i]) print (k) whois = subprocess.Popen(['whois', k], stdout=subprocess.PIPE, stderr=subprocess.PIPE) ou, err = whois.communicate() who = str(ou) print (who.find('NetName:')) who = re.split('NetName:', who)[1] who = re.split('NetHandle', who)[0] who = who.replace(r'\n', '') print (whois(k, 4)) Output: 108.160.172.204 520 None Why python return "None" not "Dropbox"? If i...

Split array into another array

c#,arrays,split
I have a string array like this: string[] Array = new string[3] {"Man(21)", "Woman(33)", "Baby(4)"}; Now I want to split this array into this scheme: Array = new string[6] {"Man", "21", "Woman", "33", "Baby", "4"}; Anybody have idea?...

why split() produces extra , after sets limit -1

java,regex,split
I want to split Area Code and preceding number from Telephone number without brackets so i did this. String pattern = "[\\(?=\\)]"; String b = "(079)25894029".trim(); String c[] = b.split(pattern,-1); for (int a = 0; a < c.length; a++) System.out.println("c[" + a + "]::->" + c[a] + "\nLength::->"+ c[a].length()); Output:...

Split string with comma delimiter but not if it is a currency value using C#

c#,regex,split
I have to split a string which contains normal values as well as currency values i.e. aaa,bbb,$33,222,ccc,$22,000 Output expected : -aaa -bbb -$33,222 -ccc -$22,000 ...

Splitting at a specific point in PDFBox

pdf,split,pdfbox
I would like to split to generate a new pdf by concatenating certain individual pages, but the last page has to be split at a certain point (i.e. all content above a limit to be included and everything below to be excluded - I only care about the ones having...