text-parsing

How to parse a string and create several columns from it?

血红的双手。 提交于 2019-12-18 08:27:42
问题 I have a varchar(max) field containing Name Value pairs, in every line I have Name UnderScore Value. I need to do a query against it so that it returns the Name, Value pairs in two columns (so by parsing the text, removing the underscore and the "new line" char. So from this select NameValue from Table where I get this text: Name1_Value1 Name2_Value2 Name3_Value3 I would like to have this output Names Values ===== ====== Name1 Value1 Name2 Value2 Name3 Value3 回答1: SELECT substring(NameValue,

How to parse a string and create several columns from it?

*爱你&永不变心* 提交于 2019-12-18 08:25:26
问题 I have a varchar(max) field containing Name Value pairs, in every line I have Name UnderScore Value. I need to do a query against it so that it returns the Name, Value pairs in two columns (so by parsing the text, removing the underscore and the "new line" char. So from this select NameValue from Table where I get this text: Name1_Value1 Name2_Value2 Name3_Value3 I would like to have this output Names Values ===== ====== Name1 Value1 Name2 Value2 Name3 Value3 回答1: SELECT substring(NameValue,

Splitting large text file by a delimiter in Python

时光总嘲笑我的痴心妄想 提交于 2019-12-17 15:58:25
问题 I imaging this is going to be a simple task but I can't find what I am looking for exactly in previous StackOverflow questions to here goes... I have large text files in a proprietry format that look comething like this: :Entry - Name John Doe - Date 20/12/1979 :Entry -Name Jane Doe - Date 21/12/1979 And so forth. The text files range in size from 10kb to 100mb. I need to split this file by the :Entry delimiter. How could I process each file based on :Entry blocks? 回答1: You could use

C# - Split Fully Uppercase String Into Separate Words (No Spaces)

六月ゝ 毕业季﹏ 提交于 2019-12-16 18:05:16
问题 Im currently working on a project where I will need to separate individual words from a string. The catch is that all the words in the string are capitalized and have no spaces. The following is an example of the kind of input the program is receiving: "COMPUTERFIVECODECOLOR" This should be split into the following result: "COMPUTER" "FIVE" "CODE" "COLOR" So far, I have been using the following method to split my strings (and it has worked for all scenarios except this edge case): private

HttpWebResponse returns an 'incomplete' stream

谁都会走 提交于 2019-12-13 21:05:47
问题 I´m making repeated requests to a web server using HttpWebRequest, but I randomly get a 'broken' response stream in return. e.g it doesn´t contain the tags that I KNOW is supposed to be there. If I request the same page multiple times in a row it turns up 'broken' ~3/5. The request always returns a 200 response so I first thought there was a null value inserted in the response that made the StreamReader think it reached the end. I´ve tried: 1) reading everything into a byte array and cleaning

Remove trailing zeros after decimal point in DB2

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 11:19:10
问题 I have the following values in label table in DB2 (version : 9.5.8) select field4 from label with ur 1.5000 0.006 9.0001 104.2500 17.0000 3.5000 Is it possible to eliminate the trailing zeros after the decimal point with an update query in DB2? If all the digits are zeros after the decimal point, I need to keep that as .0 , however. Expected output: 1.5 0.006 9.0001 104.25 17.0 3.5 回答1: You should probably consider changing the column to some kind of numeric. Anyhow, heres an idea: with t(s)

Removing values from a list in python

妖精的绣舞 提交于 2019-12-13 06:49:25
问题 I have a large file of names and values on a single line separated by a space: name1 name2 name3.... Following the long list of names is a list of values corresponding to the names. The values can be 0-4 or na. What I want to do is consolidate the data file and remove all the names and and values when the value is na . For instance, the final line of name in this file is like so: namenexttolast nameonemore namethelast 0 na 2 I would like the following output: namenexttolast namethelast 0 2

Bash shell test if all characters in one string are in another string

99封情书 提交于 2019-12-13 01:26:04
问题 I have two strings which I want to compare for equal chars, the strings must contain the exact chars but mychars can have extra chars. mychars="abcdefg" testone="abcdefgh" # false h is not in mychars testtwo="abcddabc" # true all char in testtwo are in mychars function test() { if each char in $1 is in $2 # PSEUDO CODE then return 1 else return 0 fi } if test $testone $mychars; then echo "All in the string" ; else ; echo "Not all in the string" ; fi # should echo "Not all in the string"

Extracting Arabic Proper Names from a text using Stanford-Parser

梦想的初衷 提交于 2019-12-12 23:06:05
问题 I am trying to extract Arabic proper names from a text using Stanford Parser. for example if I have an input sentence: تكريم سعد الدين الشاذلى using the Arabic Stanford parser, the tree diagram will be: (ROOT (NP (NN تكريم) (NP (NNP سعد) (DTNNP الدين) (NNP الشاذلى)))) I want to extract the proper name: سعد الدين الشاذلى which have the sub-tree: (NP (NNP سعد) (DTNNP الدين) (NNP الشاذلى)) I have tried this: similar question but there is some thing wrong in this line: List<TaggedWord>

PHP: Split a string by comma(,) but ignoring anything inside square brackets?

自作多情 提交于 2019-12-12 19:04:22
问题 How do I split a string by , but skip the one that's inside an array String - "'==', ['abc', 'xyz'], 1" When I do explode(',', $expression) it's giving me 4 item in array array:4 [ 0 => "'=='" 1 => "['abc'" 2 => "'xyz']" 3 => 1 ] But I want my output to be - array:3 [ 0 => "'=='" 1 => "['abc', 'xyz']" 2 => 1 ] 回答1: yeah, regex - select all commas, ignore in square brakets /[,]+(?![^\[]*\])/g https://regexr.com/3qudi 回答2: For your example data you might use preg_split and use a regex to match