delimiter

C++ 'Using space as a delimiter' [closed]

江枫思渺然 提交于 2019-12-14 00:10:31
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am a complete beginner in C++, and am trying to do the following program: Read a sentence from the console. Break the sentence into words using the space character as a delimiter. Iterate over each word, if the word is a numeric value then print its value doubled, otherwise print out the word, with each output

Backspace delimited flat files

梦想的初衷 提交于 2019-12-13 19:42:25
问题 Has any one ever seen a backspace delimited flat file? My requirement is to parse such a file but I am not able to put a backspace character into a file to check if I am able to detect it. 回答1: Splitting shouldn't be any harder than using any other delimiter. It's just another character, after all. In Python, for instance: >>> x = "apples\bbanana\bcoconut\bthese are delicious!" >>> x.split('\b') ['apples', 'banana', 'coconut', 'these are delicious!'] Most languages use \b as the escape

Best way to build a delimited string from a list in java

怎甘沉沦 提交于 2019-12-13 16:04:03
问题 I have a list of objects, and each object has a string property. For example, I have a List<Person> and each Person has a firstName property. I want to build a comma-delimited, quoted string that looks like this: 'James', 'Lily', 'Michael' Considering that java doesn't seem to have a join method (and besides, this is a bit more complicated than a simple delimited string), what's the most straightforward way to do this? I've been trying to code this for a bit but my code's gotten very messy

bash print whole line after splitting line with ifs

浪子不回头ぞ 提交于 2019-12-13 15:15:37
问题 When awk splits a line into fields using a delimiter, it maintains the original line in the $0 variable. Thus it can print the original line (assuming nothing else modifies $0 ) after performing operations on the individual fields. Can bash's read do something similar, where it has not only the individual elements but also the entire line? E.g., with the following input.txt foo,bar baz,quz The awk behavior that i'm trying to imitate in bash is: awk -F, '($1 == "baz") {print $0}' input.txt

Formatting string with RegExp to set delimiter

蹲街弑〆低调 提交于 2019-12-13 14:37:21
问题 I'm trying to format a string as follows Ensure all of numbers use dashes for delimiters. Example: 480.01.4430 and 480014430 would both be 480-01-4430. this is what I have come up with so far, but I can't understand why it doesn't work def format_ssns(string) ssn = string[/\d{9}/] ssn.gsub(/\d{9}/, /\d{3}-\d{2}-\d{4}/) end 回答1: It's strange that you're not getting an exception: The second argument to gsub is required to be a String (or something that can be converted to a String), not a

loading a dataset in python (numpy) when there are variable spaces delimiting columns

隐身守侯 提交于 2019-12-13 14:32:47
问题 I have a big dataset contains numeric data and in some of its rows there are variable spaces delimiting columns, like: 4 5 6 7 8 9 2 3 4 When I use this line: dataset=numpy.loadtxt("dataset.txt", delimiter=" ") I get this error: ValueError: Wrong number of columns at line 2 How can I change the code to ignore multiple spaces as well? 回答1: The default for delimiter is 'any whitespace'. If you leave loadtxt out, it copes with multiple spaces. >>> from io import StringIO >>> dataset = StringIO('

check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

孤者浪人 提交于 2019-12-13 07:20:32
问题 Here is my query CREATE TRIGGER `trigger1234` BEFORE UPDATE ON `oc_product` FOR EACH ROW BEGIN SET @json = "new:{"; SET @first = true; IF (OLD.product_id!=NEW.product_id) THEN SET @first = false; SET @json = CONCAT(@json, "\"product_id\"", ":", "\"", NEW.product_id, "\""); END IF; IF (OLD.model!=NEW.model) THEN IF (!@first) THEN SET @json = CONCAT(@json, ","); END IF; SET @first = false; SET @json = CONCAT(@json, "\"model\"", ":", "\"", NEW.model, "\""); END IF; IF (OLD.sku!=NEW.sku) THEN IF

Separate data with a comma CSV Python

偶尔善良 提交于 2019-12-13 06:52:33
问题 I have some data that needs to be written to a CSV file. The data is as follows A ,B ,C a1,a2 ,b1 ,c1 a2,a4 ,b3 ,ct The first column has comma inside it. The entire data is in a list that I'd like to write to a CSV file, delimited by commas and without disturbing the data in column A. How can I do that? Mentioning delimiter = ',' splits it into four columns on the whole. 回答1: Just use the csv.writer from the csv module. import csv data = [['A','B','C'] ['a1,a2','b1','c1'] ['a2,a4','b3','ct']]

Add comma as delimiter when creating array of arrays as one field in csv from xml data using xslt

眉间皱痕 提交于 2019-12-13 05:07:56
问题 My actual data is as follows : <image name="101272.dcm"> <gobject type="Right"><polyline><vertex index="0" t="0.0" x="636.0" y="1920.0" z="0.0"/><vertex index="1" t="0.0" x="604.0" y="2296.0" z="0.0"/></polyline></gobject> </image> <image name="101280.dcm"> <gobject type="Right"><polyline><vertex index="0" t="0.0" x="1776.0" y="392.0" z="0.0"/><vertex index="1" t="0.0" x="1456.0" y="424.0" z="0.0"/></polyline></gobject> </image> I was successful in extracting all other data as required. But

MYSQL Event Scheduler DELIMITER using PHP

牧云@^-^@ 提交于 2019-12-13 04:45:37
问题 I'm having an issue with my PHP code trying to create events within MySQL. I begin with creating a string like this: <?php $sql="DELIMITER $$ CREATE EVENT `$test_name` ON SCHEDULE EVERY $time1 $sched2 STARTS '$start_date $start_time' DO BEGIN "; $sql .="INSERT INTO blah (foo,bar); "; $sql .="END$$ DELIMITER ;"; mysql_query($sql,$dbh); ?> But I keep getting Syntax Errors starting with DELIMITER $$ CREATE EVENT . Without the semicolon behind (foo,bar); the event triggers with a unexecuted