delimiter

T-SQL — convert comma-delimited column into multiple columns

心已入冬 提交于 2019-12-08 02:07:35
问题 From the table below, how can I convert the Values column into multiple columns, populated with individual values that are currently separated by commas? Before the conversion: Name Values ---- ------ John val,val2,val3 Peter val5,val7,val9,val14 Lesli val8,val34,val36,val65,val71,val Amy val3,val5,val99 The result of the conversion should look like: Name Col1 Col2 Col3 Col4 Col5 Col6 ---- ---- ---- ---- ---- ---- ---- John val val2 val3 Peter val5 val7 val9 val14 Lesli val8 val34 val36 val65

Parser in python3 does not take delimiter values from commandline via argparse

雨燕双飞 提交于 2019-12-07 19:29:55
问题 I have written a simple script as an advanced tool for my awk / sed requirements. In the script I compare two files on basis of values from one column of the query file and then extract whole entries from the master file. The script allows you to enter the values for columns and delimiters for each file. The problem is that the 'delimiter' options are not recognized by script when given from command line. Here is my code (partial): ##- - - - - - - -- - - - - - Arguments - - - - - - - - - - -

How to strip variable spaces in each line of a text file based on special condition - one-liner in Python?

别说谁变了你拦得住时间么 提交于 2019-12-07 14:13:23
问题 I have some data (text files) that is formatted in the most uneven manner one could think of. I am trying to minimize the amount of manual work on parsing this data. Sample Data : Name Degree CLASS CODE EDU Scores -------------------------------------------------------------------------------------- John Marshall CSC 78659944 89989 BE 900 Think Code DB I10 MSC 87782 1231 MS 878 Mary 200 Jones CIVIL 98993483 32985 BE 898 John G. S Mech 7653 54 MS 65 Silent Ghost Python Ninja 788505 88448 MS

JS RegEx to match all characters (including newline) between two strings but without the two strings?

久未见 提交于 2019-12-07 12:24:45
问题 Example Text: <div id="not-wanted"> no no no </div> <div id="wanted">I want only this text </div> no no no no no <div id="not-wanted"> no no no </div> <div id="wanted">no no no no</div> <div id="wanted"> no no </div> Should deliver: I want only this text Or better: I want only this text Unfortunately, my solution catches the 2 delimitation strings also: $('#put').append(/<div id="wanted">[^<>]*<\/div>/.exec(strg)[0]); ==> <div id="wanted">I want only this text </div> Online example http:/

Split string in java for delimiter

心不动则不痛 提交于 2019-12-07 09:38:54
问题 My question is that I want to split string in java with delimiter ^ . And syntax which I am using is: readBuf.split("^"); But this does not split the string.Infact this works for all other delimiters but not for ^ . 回答1: split uses regular expressions (unfortunately, IMO). ^ has special meaning in regular expressions, so you need to escape it: String[] bits = readBuf.split("\\^"); (The first backslash is needed for Java escaping. The actual string is just a single backslash and the caret.)

How do I split “abcd efgh” into “abcd” and “efgh”?

回眸只為那壹抹淺笑 提交于 2019-12-07 04:53:27
This is really self explanatory. I'm working in a bash shell and I'm really new to shell scripting. I've found a lot of information about using tr and sed but all the examples I have found so far are removing delimiters and new lines. I really want to do the opposite of that. I want to be able to separate based on a blank space. I have a string like "abcd efgh" and I need it to be "abcd" "efgh" (all without quotes, just to show groupings). I'm sure this is much simpler than I'm making it, but I'm very confused. Updated Question: I have a column of PIDs that I have put into an array, but each

Extract data between two delimiters

為{幸葍}努か 提交于 2019-12-06 10:36:39
I just want to know whether it is possible to pick up the data that is present between two delimiters (delimiter being a string). For example the original string is as under <message%20type%3D"info"%20code%3D"20005">%20<text>Conference%20successfully%20modified</text>%20<data>0117246</data>%20%20</message>%20 and I want the data that is present between <text> tags. The string from which i need the data can be different. The string can also be like this <message%20type%3D"info"%20code%3D"20001">%20<text>Conference%20deleted</text%20%20<vanity>0116976</vanity>%20</message>%20<message%20type%3D

pandas split by last delimiter

旧巷老猫 提交于 2019-12-06 09:45:39
I have the following column in a dataframe with different outputs" col1 MLB|NBA|NFL MLB|NBA NFL|NHL|NBA|MLB I would like to use the split function to split the column by the last pipe always so something like this: col1 col2 MLB|NBA NFL MLB NBA NFL|NHL|NBA MLB With Series.str.rsplit , limiting the number of splits. df.col1.str.rsplit('|', 1, expand=True).rename(lambda x: f'col{x + 1}', axis=1) If the above throws you a SyntaxError, it means you're on a python version older than 3.6 (shame on you!). Use instead df.col1.str.rsplit('|', 1, expand=True)\ .rename(columns=lambda x: 'col{}'.format(x

Explode String in PHP

烂漫一生 提交于 2019-12-06 07:35:51
If I have a string "123x456x78", how could I explode it to return an array containing "123" as the first element and "456" as the second element? Basically, I want to take strings that are followed by "x" (which is why "78" should be thrown out). I've been messing around with regular expressions, but am having trouble. Thanks! EDIT : if the string were "123x456x78x" I would need three elements: "123", "456", "78". Basically, for each region following an "x", I need to record the string up until the next "x". Loads of different ways, but here's a RegEx as you were trying that: $str =

Using python to split a string with delimiter, while ignoring the delimiter and escape quotes inside quotes

陌路散爱 提交于 2019-12-06 07:35:01
I am trying to split a string based on the location of a delimiter (I am trying to remove comments from Fortran code). I can split using ! in the following string: x = '''print "hi!" ! Remove me''' pattern = '''(?:[^!"]|"[^"]*")+''' y = re.search(pattern, x) However, this fails if the string contains escape quotes, e.g. z = '''print "h\"i!" ! Remove me''' Can the regex be modified to handle escape quotes? Or should I not even be using regexps for this sort of problem? Here's a proven regex (from Mastering Regular Expressions ) for matching double-quoted string literals which may contain