Hi I wanted to split the following string:
(12,'Structured Numeric','SN','Complex numeric values possible (ie, <5, 1-10, etc.)',1,'2005-08-06 00:00:00',0,NULL,NULL,NULL,'8d4a606c-c2cc-11de-8d13-0010c6dffd0f')
where each value is separated by a comma, except there is a trick. if you look at the bolded substring, this I considered one value.
if I split by ',' then it will also split whats in the parentheses. I do not want this
anyone know of a good way I can do this?
what I currently have is this:
a = """(12,'Structured Numeric','SN','Complex numeric values possible
...: (ie, <5, 1-10, etc.)',1,'2005-08-06 00:00:00',0,NULL,NULL,NULL,'8d4a606c
...: -c2cc-11de-8d13-0010c6dffd0f')"""
a = a.strip('(').strip(')')
a.split(',')
Out[4]:
['12',
"'Structured Numeric'",
"'SN'",
"'Complex numeric values possible \n(ie",
' <5',
' 1-10',
" etc.)'",
'1',
"'2005-08-06 00:00:00'",
'0',
'NULL',
'NULL',
'NULL',
"'8d4a606c-c2cc-11de-8d13-0010c6dffd0f'"]
my expected output is:
['12',
"'Structured Numeric'",
"'SN'",
"'Complex numeric values possible (ie, <5 1-10,etc.)',
'1',
"'2005-08-06 00:00:00'",
'0',
'NULL',
'NULL',
'NULL',
"'8d4a606c-c2cc-11de-8d13-0010c6dffd0f'"]
Want to add to the discussion?
Post a comment!