Split comma separated values of a column in row, through Oracle SQL query

Try using below query: WITH T AS (SELECT ‘A,B,C,D,E,F’ STR FROM DUAL) SELECT REGEXP_SUBSTR (STR, ‘[^,]+’, 1, LEVEL) SPLIT_VALUES FROM T CONNECT BY LEVEL <= (SELECT LENGTH (REPLACE (STR, ‘,’, NULL)) FROM T) Below Query with ID: WITH TAB AS (SELECT ‘1001’ ID, ‘A,B,C,D,E,F’ STR FROM DUAL ) SELECT ID, REGEXP_SUBSTR (STR, ‘[^,]+’, 1, LEVEL) … Read more

Split a text into single words

Use the class \p{P} which matches any unicode punctuation character, combined with the \s whitespace class. $result = preg_split(‘/((^\p{P}+)|(\p{P}*\s+\p{P}*)|(\p{P}+$))/’, $text, -1, PREG_SPLIT_NO_EMPTY); This will split on a group of one or more whitespace characters, but also suck in any surrounding punctuation characters. It also matches punctuation characters at the beginning or end of the string. … Read more

Splitting multiple columns into rows in pandas dataframe

You can first split columns, create Series by stack and remove whitespaces by strip: s1 = df.value.str.split(‘,’, expand=True).stack().str.strip().reset_index(level=1, drop=True) s2 = df.date.str.split(‘,’, expand=True).stack().str.strip().reset_index(level=1, drop=True) Then concat both Series to df1: df1 = pd.concat([s1,s2], axis=1, keys=[‘value’,’date’]) Remove old columns value and date and join: print (df.drop([‘value’,’date’], axis=1).join(df1).reset_index(drop=True)) ticker account value date 0 aa assets 100 20121231 … Read more

How can I split a string of a mathematical expressions in python?

Tree with ast You could use ast to get a tree of the expression : import ast source=”((81 * 6) /42+ (3-1))” node = ast.parse(source) def show_children(node, level=0): if isinstance(node, ast.Num): print(‘ ‘ * level + str(node.n)) else: print(‘ ‘ * level + str(node)) for child in ast.iter_child_nodes(node): show_children(child, level+1) show_children(node) It outputs : <_ast.Module … Read more

How to split a Python string on new line characters [duplicate]

✨ Splitting line in Python: Have you tried using str.splitlines() method?: Python 2.X documentation here. Python 3.X documentation here. From the docs: str.splitlines([keepends]) Return a list of the lines in the string, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true. For example: >>> ‘Line … Read more

splitting a string based on multiple char delimiters

Use string.Split(char []) string strings = “4,6,8\n9,4”; string [] split = strings .Split(new Char [] {‘,’ , ‘\n’ }); EDIT Try following if you get any unnecessary empty items. String.Split Method (String[], StringSplitOptions) string [] split = strings .Split(new Char [] {‘,’ , ‘\n’ }, StringSplitOptions.RemoveEmptyEntries); EDIT2 This works for your updated question. Add all … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)