delimiter

MySQL delimiter syntax error

谁说我不能喝 提交于 2019-11-26 21:23:08
问题 I'm trying to change the MySQL command delimiter so I can create a procedure with multiple commands in it. However, the delimiter command does not seem to be recognised on MySQL 5.1.47. I tested it on MySQL 5.0.91, and it did work there. DELIMITER //; DELIMITER ;// I'm trying to run this from phpmyadmin, in both situations. Using 5.0.91 instead isn't an option because I need to use events ( CREATE EVENT ). Error message: #1064 - You have an error in your SQL syntax; check the manual that

Can I import a CSV file and automatically infer the delimiter?

拈花ヽ惹草 提交于 2019-11-26 20:05:55
问题 I want to import two kinds of CSV files, some use ";" for delimiter and others use ",". So far I have been switching between the next two lines: reader=csv.reader(f,delimiter=';') or reader=csv.reader(f,delimiter=',') Is it possible not to specify the delimiter and to let the program check for the right delimiter? The solutions below (Blender and sharth) seem to work well for comma-separated files (generated with Libroffice) but not for semicolon-separated files (generated with MS Office).

How to specify more spaces for the delimiter using cut?

坚强是说给别人听的谎言 提交于 2019-11-26 18:45:49
问题 Is there any way to specify a field delimiter for more spaces with the cut command? (like " "+) ? For example: In the following string, I like to reach value '3744', what field delimiter I should say? $ps axu | grep jboss jboss 2574 0.0 0.0 3744 1092 ? S Aug17 0:00 /bin/sh /usr/java/jboss/bin/run.sh -c example.com -b 0.0.0.0 cut -d' ' is not what I want, for it's only for one single space. awk is not what I am looking for either, but how to do with 'cut'? thanks. 回答1: Actually awk is exactly

Split a string into words by multiple delimiters

大城市里の小女人 提交于 2019-11-26 16:06:13
I have some text (meaningful text or arithmetical expression) and I want to split it into words. If I had a single delimiter, I'd use: std::stringstream stringStream(inputString); std::string word; while(std::getline(stringStream, word, delimiter)) { wordVector.push_back(word); } How can I break the string into tokens with several delimiters? Assuming one of the delimiters is newline, the following reads the line and further splits it by the delimiters. For this example I've chosen the delimiters space, apostrophe, and semi-colon. std::stringstream stringStream(inputString); std::string line;

JS string.split() without removing the delimiters [duplicate]

天大地大妈咪最大 提交于 2019-11-26 14:38:42
This question already has an answer here: Split string into array without deleting delimiter? 5 answers How can I split a string without removing the delimiters? Let's say I have a string: var string = "abcdeabcde"; When I do var newstring = string.split("d") , I get something like this: ["abc","eabc","e"] But I want to get this: ["abc","d","eabc","d","e"] When I tried to do my "split2" function, I got all entangled in splice() and indexes and "this" vs "that" and ... aargh! Help! :D InfoLearner Try this: Replace all of the "d" instances into ",d" Split by "," var string = "abcdeabcde"; var

C# List<string> to string with delimiter

心已入冬 提交于 2019-11-26 14:02:15
Is there a function in C# to quickly convert some collection to string and separate values with delimiter? For example: List<string> names --> string names_together = "John, Anna, Monica" Quartermeister You can use String.Join . If you have a List<string> then you can call ToArray first: List<string> names = new List<string>() { "John", "Anna", "Monica" }; var result = String.Join(", ", names.ToArray()); In .NET 4 you don't need the ToArray anymore, since there is an overload of String.Join that takes an IEnumerable<string> . You can also do this with linq if you'd like var names = new List

How to make the &#39;cut&#39; command treat same sequental delimiters as one?

大憨熊 提交于 2019-11-26 13:59:41
I'm trying to extract a certain (the fourth) field from the column-based, 'space'-adjusted text stream. I'm trying to use the cut command in the following manner: cat text.txt | cut -d " " -f 4 Unfortunately, cut doesn't treat several spaces as one delimiter. I could have piped through awk awk '{ printf $4; }' or sed sed -E "s/[[:space:]]+/ /g" to collapse the spaces, but I'd like to know if there any way to deal with cut and several delimiters natively? kev Try: tr -s ' ' <text.txt | cut -d ' ' -f4 From the tr man page: -s, --squeeze-repeats replace each input sequence of a repeated character

Escaping separator within double quotes, in awk

时光毁灭记忆、已成空白 提交于 2019-11-26 13:44:48
I am using awk to parse my data with "," as separator as the input is a csv file. However, there are "," within the data which is escaped by double quotes ("..."). Example filed1,filed2,field3,"field4,FOO,BAR",field5 How can i ignore the comma "," within the the double quote so that I can parse the output correctly using awk? I know we can do this in excel, but how do we do it in awk? Dimitre Radoulov It's easy, with GNU awk 4 : zsh-4.3.12[t]% awk '{ for (i = 0; ++i <= NF;) printf "field %d => %s\n", i, $i }' FPAT='([^,]+)|("[^"]+")' infile field 1 => filed1 field 2 => filed2 field 3 => field3

R semicolon delimited a column into rows

随声附和 提交于 2019-11-26 12:33:45
问题 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 columns in connection. any help on this would be grand. Code that is working for 2 of the columns is below. v1 <- with(df, tapply(PolId, Description, FUN= function(x) { x1 <- paste(x, collapse=\";\") gsub(\'(\\\\b\\\\S+\\\\b)(?=.*\\\\b\\\\1\\\

What delimiters can you use in sed?

泪湿孤枕 提交于 2019-11-26 12:19:30
问题 We normally see people complaining about the unknown option to s\' error in sed when they want to use a pattern that contains the sed delimiter. For example, if we are using / : $ var=\"hel/lo\" $ sed \"s/a/$var/g\" <<< \"haha\" sed: -e expression #1, char 9: unknown option to `s\' So we advise to use another delimiter, for example | : $ sed \"s|a|$var|g\" <<< \"haha\" hhel/lohhel/lo However, I want to know what are the possible delimiters sed can accept... since it seems to be almost any