I had a question (answered excellently) here: Python parse dataframe element
Unfortunately, my data source has other conditions which need handled.
Current pattern is
pattern = r'([^\(]+)(\(([^,]*),(.*)\))?'
trans_field_attr = df['Data Type'].str.extract(pattern, expand=True).iloc[:, [0, 2, 3]]
This handles the (precision,scale) version perfectly e.g NUMBER(22,4). Unfortunately it does not select any values in brackets where there is only a single value.
For example:
0 VARCHAR2(1)
1 VARCHAR2(1)
2 VARCHAR2(1)
3 VARCHAR2(1)
4 VARCHAR2(1)
5 DATE(7)
6 DATE(7)
7 DATE(7)
8 DATE(7)
9 VARCHAR2(1)
10 DATE(7)
11 VARCHAR2(3)
12 VARCHAR2(3)
13 NaN
14 VARCHAR2(3)
15 NUMBER(22,4)
How could the pattern be improved to pickup single values as well?
Apologies but I really struggled to take it further from piRSquared's answer...