delimiter

Dynamic SQL Comma-Delimited Value Query

我是研究僧i 提交于 2019-12-01 06:04:44
问题 [Update: Using SQL Server 2005] Hi, what I want to do is query my stored procedure with a comma-delimited list of values (ids) to retrieve rows of data. The problem I am receiving is a conversion error: Conversion failed when converting the varchar value ' + @PassedInIDs + ' to data type int. The statement in my where-clause and error is: ... AND (database.ID IN (' + @PassedInIDs + ')) Note: database.ID is of int type. I was following the article at: http://www.sql-server-helper.com/functions

How to determine the end of a line with a Scanner?

大憨熊 提交于 2019-12-01 04:01:29
I have a scanner in my program that reads in parts of the file and formats them for HTML. When I am reading my file, I need to know how to make the scanner know that it is at the end of a line and start writing to the next line. Here is the relevant part of my code, let me know if I left anything out : //scanner object to read the input file Scanner sc = new Scanner(file); //filewriter object for writing to the output file FileWriter fWrite = new FileWriter(outFile); //Reads in the input file 1 word at a time and decides how to ////add it to the output file while (sc.hasNext() == true) {

How to determine the end of a line with a Scanner?

不想你离开。 提交于 2019-12-01 01:35:35
问题 I have a scanner in my program that reads in parts of the file and formats them for HTML. When I am reading my file, I need to know how to make the scanner know that it is at the end of a line and start writing to the next line. Here is the relevant part of my code, let me know if I left anything out : //scanner object to read the input file Scanner sc = new Scanner(file); //filewriter object for writing to the output file FileWriter fWrite = new FileWriter(outFile); //Reads in the input file

Javascript split at multiple delimters while keeping delimiters

丶灬走出姿态 提交于 2019-11-30 19:37:01
Is there a better way than what I have (through regex, for instance) to turn "div#container.blue" into this ["div", "#container", ".blue"]; Here's what I've have... var arr = []; function process(h1, h2) { var first = h1.split("#"); arr.push(first[0]); var secondarr = first[1].split("."); secondarr[0] = "#" + secondarr[0]; arr.push(secondarr[0]); for (i = 1; i< secondarr.length; i++) { arr.push(secondarr[i] = "." + secondarr[i]); } return arr; } Why not something like this? 'div#container.blue'.split(/(?=[#.])/); Because it's simply looking for a place where the next character is either # or

How to get mysqli working with DELIMITERs in SQL statements?

泪湿孤枕 提交于 2019-11-30 18:55:32
问题 I'm using mysqli and trying now to get a view from an SQL code snippet (generated by MySQL Workbench) into a database. $query = <<<QUERY DROP VIEW IF EXISTS `myview` ; SHOW WARNINGS; DROP TABLE IF EXISTS `myview`; SHOW WARNINGS; DELIMITER $$ CREATE OR REPLACE VIEW `myview` AS ...view definition... $$ DELIMITER ; ; SHOW WARNINGS; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; QUERY; $result = mysqli_multi_query($dbConnection,

How to programmatically guess whether a CSV file is comma or semicolon delimited

久未见 提交于 2019-11-30 17:36:23
In most cases, CSV files are text files with records delimited by commas. However, sometimes these files will come semicolon delimited. (Excel will use semicolon delimiters when saving CSVs if the regional settings has the decimal separator set as the comma -- this is common in Europe. Ref: http://en.wikipedia.org/wiki/Comma-separated_values#Application_support ) My question is, what is the best way to have a program guess whether to have it comma or semicolon separated? e.g. a line like 1,1;1,1 may be ambiguous. It could be interpreted comma delimited as: 1 1;1 (a string) 1 or semicolon

Windows batch file - splitting a string to set variables

半城伤御伤魂 提交于 2019-11-30 15:24:15
I feel like I'm going around in circles with FOR loop options. I'm trying to take a string (output of a command) and split it on commas, then use each value to SET, e.g. String: USER=Andy,IP=1.2.3.4,HOSTNAME=foobar,PORT=1234 So I want to split on comma and then literally use that variable in SET. I don't know ahead of time how many many variables there will be. I've tried things like: FOR %%L IN (%MYSTRING%) DO ECHO %%L but that splits on the equals sign too so I end up with USER Andy IP 1.2.3.4 etc I just want to be able to do the following so I can SET USER=Andy etc, something like: FOR %%L

Why the field separator character must be only one byte?

牧云@^-^@ 提交于 2019-11-30 14:12:51
问题 data <- read.delim("C:\\test.txt", header = FALSE, sep = "$$$$$") Error in scan(file, what = "", sep = sep, quote = quote, nlines = 1, quiet = TRUE, : invalid 'sep' value: must be one byte Why there is a restriction like this? Can I overcome it? 回答1: Here is a potential solution. Assuming this is what the lines in your file look like 1$$$$$2$$$$$3$$$$$4 The following will create a matrix with the variables stored as characters. do.call(rbind,strsplit(readLines('test.txt'),'$$$$$',fixed=T)) 来源

How to split String before first comma?

旧巷老猫 提交于 2019-11-30 13:00:15
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: String before first comma and String after first comma My overriding method is : @Override protected void onPostExecute(String addressText) { placeTitle.setText(addressText); } Now how do I split the string into two parts, so that I can use them to set the text in two different TextView ? Razib You may use the following code snippet String str ="abc,cde,def,fgh"; String kept = str.substring( 0, str.indexOf(",")); String remainder = str.substring(str

Convert a delimted string to a dictionary<string,string> in C#

荒凉一梦 提交于 2019-11-30 11:47:15
问题 I have a string of the format "key1=value1;key2=value2;key3=value3;" I need to convert it to a dictionary for the above mentioned key value pairs. What would be the best way to go about this? Thanks. 回答1: Something like this? var dict = text.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries) .Select(part => part.Split('=')) .ToDictionary(split => split[0], split => split[1]); Of course, this will fail if the assumptions aren't met. For example, an IndexOutOfRangeException could be