FAQ Database Discussion Community


How do I split a string into an array

java,arrays,string,split,delimiter
I am trying to split each line of a String read by my FileReader and BufferedReader. I am getting a syntax error at String [] x = Login.Split(""); What method can I use to split the String? I will be adding a method to see if the string matches made...

string.Split C# keeps text outside delimiters

c#,delimiter
I am trying to take a list of eMail addresses along with first and last names and convert them to a CSV format. My eMail addresses are in the following format: First, Last <email1@example.com>; First, Last <email2@example.com>; The output I need is the following: email1@example.com,email2@example.com I am using the following...

Read file, check correctness of column, write file C#

c#,visual-studio,file-io,delimiter
I need to check certain columns of data to make sure there are no trailing blank spaces. At first thought I thought it would be very easy, but after attempting to achieve the goal I have got stuck. I know that there should be 6-digits in the column I need...

Replace all the values in a certain column with certain values using csv reader Python

python,csv,delimiter
This is the question continous from my previous question. Thank to many people, I could modify my code as below. import csv with open("SURFACE2", "rb") as infile, open("output.txt", "wb") as outfile: reader = csv.reader(infile, delimiter=" ") writer = csv.writer(outfile, delimiter=" ") for row in reader: row[18] = "999" writer.writerow(row) I...

How do I delimit a fetched data record on MySQL?

mysql,delimiter,pipeline,text-formatting
I have a column which returns pipeline delimited records as below: 'fromState=A|Count=5|highLimit=B|status=C|presentValue=D|alarmValue=E' Is there a way to have it as a more formatted output like: 'fromState=A Count=5 highLimit=B status=C presentValue=D alarmValue=E' i.e., pipelines are replaced each value is on a new line (optional) ...

Reading CSV File Using Scanner Class Error

java,csv,java.util.scanner,delimiter
I have an original code that came from a Java book example. The program simply reads a text file ("clients.txt"). However, I would like to modify the "clients.txt" into a "clients.csv" and have the program read ".csv" file instead. I have parsed the data with "," as the delimiter according...

Can I put strings divided by newlines into an array using the read builtin?

arrays,string,bash,newline,delimiter
I have a variable: var='/path/to/filename.ext /path/to/filename2.ext /path/to/filename3.ext' I want to put all strings separated by a newline in an array: declare -a arr Based on numerous posts here on StackOverflow, I found a couple of ways: # method 1: while loop while read line; do arr+=($line) done <<< "$var" #...

Extract ID's separated by dashes from text string

sas,delimiter
I have a dataset that has one concatenated text field. I am trying to break it into three text columns in SAS 9.4. Obs Var1 1 MAY12-KANSAS-ABCD6194-XY7199-BRULE 2 JAN32-OHIO-BZ5752-GARY My output for observation 1 should look like this: Obs Date State ID 1 MAY12 KANSAS ABCD6194-XY7199-BRULE Here's what I have,...

confusing syntax of cin.get()

c++,get,delimiter
I read a book which mentions that cin.get() will keep delimiter in the input stream, thus, the result of a following consecutive calling with the same delimiter is an empty line. So I wrote the following code to test this property and other. #include <iostream> using namespace std; int main()...

How do you modify a string splitting function to ignore consecutive delimiters?

c,string,split,delimiter
I am using a function that was posted as an answer on another Stackoverflow question. The user who posted this however notes that: it does not handle consecutive delimiters. I am wondering how I can modify this so that it could handle consecutive delimiters? I want to essentially ignore it...

Delimiter in java

java,delimiter
I am trying to use a delimiter in Java, but it won't work(the standard white space delimiter is working). My code is this: Scanner input = new Scanner(System.in); System.out.println("Enter the first rational number seperated by '/':"); input.useDelimiter("/"); int numerator1 = input.nextInt(); int denominator1 = input.nextInt(); System.out.println(numerator1 + denominator1); When I...

VBScript to split a text file into multiple files based on a variables that needs to be set from file contents

variables,vbscript,split,delimiter
I am hoping that someone will be able to help me out, basically I have a text file that I need to split based on a variable that will be contained within the file….. I have added below an example of how the source file would look… What I need...

split string into array with multiple delimiters shell

arrays,bash,delimiter,string-split
I have a text file having contents in format... File=/opt/mgtservices/probes/logs is_SS_File=no is_Log=yes Output_File=probes_logs This can have around 1k records. I am reading line by line from a file. while read -r line do if [ $SS_SERVER -eq 0 ] then arr=$(echo "$line" | tr ' =' "\n") echo $arr[1] #do...

HIVE: apply delimiter until a specified column

hadoop,datatable,hive,delimiter
I am trying to move data from a file into a hive table. The data in the file looks something like this:- StringA StringB StringC StringD StringE where each string is separated by a space. The problem is that i want separate columns for StringA, StringB and StringC and one...

Split up serial data in delphi

delphi,serial-port,delphi-7,delimiter,arduino-uno
I am a newbie in Delphi programming and I need some help. I have a problem with spliting my serial data. This is my code: procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer); var DataByte : string; x, i: integer; save_data : TStringList; begin save_data := TStringList.create; for x := 0 to Count-1...

Last delimiter seems wrong

java,regex,delimiter
I have a text file with the following String: I want to know. bye bye. I found you. I hate you. I hear you. What I want to do is to search for a target sentence inside a file. This is the code that I use: public String lookFor(String target,...

Use array of delimiters

php,csv,delimiter
I'm using fgetcsv to read csv files in my application. Problem is that I don't know if my users will use ,, |, or ; as delimiters. If I tell fgetcsv nothing it will only accept , but if I tell it to use a specific delimiter it will only...

How to split text file based on number of space delimiters - Notepad++

notepad++,delimiter
First time asking a question here so please let me know if more information is needed. Here is an example of the data I am trying to parse into multiple rows: 0 0 159 190 145 20 0 1 159 166 127 21 0 2 159 144 111 22 0...

Parse String without removing the token [closed]

java,regex,parsing,delimiter
I have a string to parse in java. My input string is : #hello#adam@how@are@you. I expect the output to be: #hello #adam @how @are @you I have tried with the following code but it is not giving the desired output. StringTokenizer st = new StringTokenizer(txt,"#,"); ArrayList<String> str =new ArrayList<String>(); while...

R semicolon delimited a column into rows

r,split,delimiter
I am using RStudio 2.15.0 and have created an object from Excel using XLConnect with 3000+ rows and 12 columns I am trying to delimit/split a column into the rows but don't know if this is possible or how to do it. Example of the data below using the 3...

SCALA: change the separator in Array

arrays,string,scala,delimiter
I have an Array like this. scala> var x=Array("a","x,y","b") x: Array[String] = Array(a, x,y, b) How do I change the separator comma in array to a :. And finally convert it to string like this. String = "a:x,y:b" My aim is to change the comma(separators only) to other separator(say,:), so...

AngularJS and Laravel Blade: Module Error when changing the interpolateProvider (Delimiter)

angularjs,laravel-5,delimiter,blade,angularjs-interpolate
I have a strange problem when combining Laravel 5 (with Blade) and Angular 1.3. I am experienced with Laravel, but a newbie with Angular. I know that I have to change Angular's delimiters to be able to make it work with Laravel's Blade. So here is what I did: //app.js...

Splitting lines by delimiter in large file

linux,file,split,line,delimiter
I have a file in this format: a(tab)b(tab)c some lines do not have a c column What I need to do is take the b column out of every line? What would be the best way to accomplish this?...

Python line.split between two delimeters

python,delimiter
I have a text file that contains the following data: Schema: Column Name Localized Name Type MaxLength ---------------------------- ---------------------------- ------ --------- Raw Binary Binary 16384 Row 1: Binary: -----BEGIN----- fdsfdsfdasadsad fsdfafsdafsadfa fsdafadsfadsfdsa -----END----- Row 2: Binary: -----BEGIN----- fsdfdssd fdsfadsfasd fsdafdsa -----END----- Row 3: Binary: -----BEGIN----- fsdafadsds fsdafasdsda fdsafadssad -----END----- I...

Syntax error preventing CREATE EVENT

mysql,database,delimiter,mysql-error-1064,ddl
CREATE EVENT demo ON SCHEDULE EVERY 2 SECOND DO BEGIN update alarm set is_on=1; END Error SQL query: CREATE EVENT demo ON SCHEDULE EVERY 2 SECOND DO BEGIN update alarm set is_on=1; MySQL said: Documentation 1064 - You have an error in your SQL syntax; check the manual that corresponds...

SQL*Loader does not recognize delimiter “¥”

oracle,utf-8,delimiter,sql-loader
When trying to load an UTF-8 file with ¥ separator, it doesn't separate the fields when it finds the character. We get an ORA-12899 error from the value exceeding the column size, since it tries to put the entire line into the first column. In UTF-8 , ¥ is Â¥...

Remove Single Spaces From String

r,delimiter
I am working to parse some difficult data and need to remove just the single spaces. The rows of my data look like the example below [1] " Class Dist Quantity Market Taxable/$ " [2] " 4-2101 THIS LAND 28 108.85 216797 6352.00 " [3] "99-9084 FIRE PROTECTION 9084 0.00...

Reading from a CSV file and solving problems with “;”

c,csv,scanf,delimiter
I have this CSV file and I have to read it and print each different customer (each line is a customer) IDClient;Name;Surname;Address;City;State;Postal_Code 111A;Howard;Snyder;2732 Baker Blvd.;Eugene;OR;97403 222B;Yoshi;Latimer;City Center Plaza 516 Main St.;Elgin;OR;97827 333C;John;Steel;12 Orchestra Terrace;Walla Walla;WA;99362 444D;Jaime;Yorres;87 Polk St. Suite 5;San Francisco;CA;94117 I wrote this code and despite some warnings seems...

Powershell out-file csv delimiting

powershell,csv,delimiter,robocopy
I have a powershell command using robocopy to list files. I am trying to output to csv but it does not separate the columns as needed. I get two columns where there should be 5. is there a delimiter parameter for out-file csv? Here is the current code: robocopy .\Documents\...

Cannot cin.ignore till EOF?

c++,delimiter,cin,flush,ignore
I wanted to ignore all characters in cin to flush cin in this answer: How to get rid of bad input one word at a time instead of one line at a time? But I found that the program seemed to hang awaiting input if I wrote: cin.ignore(std::numeric_limits<std::streamsize>::max()); It propperly...

How to split String before before first comma?

java,android,string,delimiter
I have an overriding method with String which returns String in format of: "abc,cde,def,fgh" I want to split the string Content into two parts: 1) String before first comma and 2) String after first comma My overriding method is : @Override protected void onPostExecute(String addressText) { placeTitle.setText(addressText); } Now how...

Preg_split, how to keep delimiter?

php,html,regex,delimiter,preg-split
I'm trying to keep preg_split delimiter (< tr > and < /tr >) without separate it in a new array position and can't figure it out. So any help will be appreciated. I'm trying to take every row from the next html code and put it in a different array...

StreamReader row and line delimiters

c#,arrays,tokenize,delimiter,streamreader
I am trying to figure out how to tokenize a StreamReader of a text file. I have been able to separate the lines, but now I am trying to figure out how to break down those lines by a tab delimiter as well. This is what I have so far....

Seperate first and last names from single column

sql,postgresql,substring,delimiter
I have a person table where the name column contains names, some in the format "first last" and some in the format "first". My query SELECT name, SUBSTRING(name FROM 1 FOR POSITION(' ' IN name) ) AS first_name FROM person creates a new row of first names, but it doesn't...

Writing to Text File from Comma Delimited ArrayList

java,file-io,arraylist,delimiter,printwriter
I have created a Song class that includes data members for a Song (Title, artist, album,length). I already have a .txt file that contains different songs which is stored into an array list. After the user finishes adding or deleting songs the program should write to the text file in...

Implementing `strtok` whose delimiter has more than one character

c,delimiter,strtok,c-strings
Code snippet: char str[] = "String1::String2:String3:String4::String5"; char *deli = "::"; char *token = strtok(str,deli); while(token != NULL) { printf("Token= \"%s\"\n", token); token=strtok(NULL,deli); } The above code snippet produces the output: Token="String1" Token="String2" Token="String3" Token="String4" Token="String5" but I want the output to be: Token="String1" Token="String2:String3:String4" Token="String5" I know that I am...

Using a delimiter in a method (Java)

java,java.util.scanner,delimiter
I have to read in input from a line of a text file : 1165,24 1305,27 1345,12 1360,10 1388,15 1388,20 1495,32 1680,36 and send it to a method that will build a Sales object with the first number on the line being the Product Code and the second being the...

Assigning a variable through the end of the array

c#,arrays,loops,split,delimiter
I am trying to figure out if there is a way to assign my last variable (var4) to the rest of my array after [2]. static void Main(string[] args) { string var1; string var2; string var3; string var4; string readContents; using (StreamReader streamReader = new StreamReader(@"File.txt")) { readContents = streamReader.ReadToEnd();...

How to use Java delimiter patterns?

java,regex,string,delimiter
I'm trying to figure out how to use delimiter patterns in Java. I have tried googling and searching stack overflow but I can't find anything that answers my questions. How do you set patterns for useDelimiter? I'm trying to set a delimiter that separates text once it finds < and...

How to cut varchar/text before n'th occurence of delimiter? PostgreSQL

sql,postgresql,split,delimiter,cut
I have strings (saved in database as varchar) and I have to cut them just before n'th occurence of delimiter. Example input: String: 'My-Example-Awesome-String' Delimiter: '-' Occurence: 2 Output: My-Example I implemented this function for fast prototype: CREATE OR REPLACE FUNCTION find_position_delimiter(fulltext varchar, delimiter varchar, occurence integer) RETURNS varchar AS...

Java string.split( ) on comma or end-of-line [duplicate]

java,regex,string,delimiter,stringtokenizer
This question already has an answer here: Java String's split method ignores empty substrings 2 answers I'm terrible with regex stuff. I have data that looks like this: abc,42,4/04/1992,,,something, ,2/05/2007,dkwit,,334,,, The meaning of the data itself is somewhat irrelevant, the point is that it's comma-delimited, you could refer to...

How to get value from access database to a combobox but split the collection(delimited by semicolons)?

.net,vb.net,visual-studio-2010,ms-access-2010,delimiter
I have an access database containing cells in this format Type1;Type2;Type3 I want bring those value in a combobox so the combobox collection look like this: Type1 Type2 Type3 I know of to get the value here is my code: 'type_text is the name of the combobox Dim ds As...

PHP semicolon delimited file generation

php,excel,delimiter
I am using this code to generate a Semicolon delimited file: for ($i = 0; $i < 3; $i = $i+1) { array_push($dataArray,"$dataCell1","$dataCell2","$dataCell3","$dataCell4","$dataCell5","$dataCell6","$dataCell7","$dataCell8","$dataCell9","$dataCell10","$dataCell11"); $stringData = rtrim(implode(';', $dataArray), ';'); //rtrim will prevent the last cell to be imploded by ';' $stringData .= "\r\n"; } What I want is: (Data separated by...

Where IN a Comma delimited string [duplicate]

sql-server,delimiter,where-in
This question already has an answer here: Passing a varchar full of comma delimited values to a SQL Server IN function 13 answers I would like retrieve a certain users from a full list of a temp table #temptable. The query is like this: Declare @List varchar(max) Select @List...

PHP mb_split(), capturing delimiters

php,delimiter,capture,preg-split,multibyte
preg_split has an optional PREG_SPLIT_DELIM_CAPTURE flag, which also returns all delimiters in the returned array. mb_split does not. Is there any way to split a multibyte string (not just UTF-8, but all kinds) and capture the delimiters? I'm trying to make a multibyte-safe linebreak splitter, keeping the linebreaks, but would...

How to disable dots as delimiters in sqldeveloper (import data from csv)?

csv,oracle-sqldeveloper,delimiter
I am trying to import data to oracle database from csv file. In csv file i use "," as separator. I have problem with column "amount" where I have to put amount of 2 decimal places separated by a dot. I don`t know why, sql developer treats the dot as...

Weird Delimiter

python,python-2.7,parsing,delimiter
In Python, I am trying to parse a file and separate values, however, I am working with a weird delimiter. Could anyone help out? Thanks! The lines in the file I am parsing appear similarly as: john-burk AL john-smith CA john-joe FL john-john TX Current code: with open('info.txt', 'r') as...

Prefixing an Applescript text items list

applescript,delimiter
I have the following code, which prompts user for a comma separated list of places: set AppleScript's text item delimiters to {","} set thePlaces to the text items of the text returned of (display dialog "Insert referenced places separated by commas" default answer "") This will result on a list...

Reformat text file to csv that includes two different delimiter in python

python,delimiter
I have a text file like the following: A+B,item_1,item_2 C+D,item_3,item_4 E+F+G,item_5,item_6,item_7 I was trying to use python to reformat it to a csv file like the following specific order: B,item_1 A,item_2 D,item_3 C,item_4 G,item_5 F,item_6 E,item_7 How would I do this in python? EDITED: I have tried many different things...

Adding and Subtracting numbers from a String

java,regex,string,delimiter
This program takes in a string and adds up all the integers in it, I have set the delimiter to be "+" surrounded by any amount of white space. It works fine with that but now I want it to work with any negative integers as well, for instance if...

How to split multiple big text files into multiple files using powershell

file,powershell,split,delimiter
I have a folder with 1 or more files like this: bigfileA.txt bigfileB.txt bigfileC.txt Each file contains 1 line and is delimited by ' For example, bigfileA.txt may contain abcdef'ghijklmnop'qrst How can I use powershell so that when I run the .ps file it will automatically split all files in...

Error Code: 1064 | Delimiter

mysql,delimiter
DELIMITER $$ ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_t_buku_bank` AS SELECT `b`.`id` AS `id`, `b`.`no_bku` AS `no_bku`, `b`.`tanggal` AS `tanggal`, `b`.`tanggal_bayar` AS `tanggal_bayar`, `b`.`id_transaksi_bank` AS `id_transaksi_bank`, `b`.`no_bukti` AS `no_bukti`, `b`.`jumlah` AS `jumlah`, `b`.`id_akun_pendapatan` AS `id_akun_pendapatan`, `ap`.`kode` AS `pendapatan_kode`, `m`.`jenis` AS `jenis`, `m`.`nama` AS `transaksi`, `ap`.`nama` AS `pendapatan`, IF((`m`.`jenis` =...