I'm trying to split the following type of string in Python 2.7 in order to convert it into a list of values:
s = "19, '8X','1Gb', '1.5 GHz dual-core',342,'4.3', '720x1280','32,35 x 66,2 x 10,12', 130, '', 4, 9"
I would like to get a list of values similar to:
list_s = [19, '8X', '1Gb', '1.5 GHz dual-core', 342, '4.3', '720x1280', '32,35 x 66,2 x 10,12', 130, ' ', 4, 9]
I tried to used the function split() and the function re.split() in the following way:
list_s = s.split(",")
#OUTPUT = ['19', " '8X'", " '1Gb'", " '1.5 GHz dual-core'", ' 342', " '4.3'", " '720x1280'", " '32", '35 x 66', '2 x 10', "12'", ' 130', " ''", ' 4', ' 9']
list_s2 = re.split("([`]|[']|[\"]){1}[,]", s)
#OUTPUT = ["19, '8X", "'", " '1Gb", "'", " '1.5 GHz dual-core", "'", " 342, '4.3", "'", " '720x1280", "'", " '32,35 x 66,2 x 10,12", "'", " 130, '", "'", ' 4, 9']
Can you suggest me a solution for this problem?