currently working with the below command:
python foo.py "['A,B,C,D','A,B,C','A,B','A']"
And I want to transform it into an actual string array:
A[0] = 'A,B,C,D'
A[1] = 'A,B,C'
A[2] = 'A,B'
A[3] = 'A'
At the moment, I've been trying to use json.loads()
and sys
to read the string into an object or list.
However, it seems that the presence of the single-quotes cause the following error.
ValueError: No JSON object could be decoded
Yet, without the single-quotes, I end up the array:
B = ["A","B","C","D","A","B","C","A","B","A"]
How to get Python to ignore the inner commas while keeping track of the outer commas in order to produce the array of strings given in A
shown above?