Python Forum

Full Version: Splitting String into 2d list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a sample list of data as follows

'762-69-7639,Aime,Gentzsch,12ALT,ENG LIT,MUSIC,PSYCHOL
359-53-2130,Marrick,Spinelli,12POL,MATHS,COMPSCI,PHYSICS
460-96-3787,Isaac,Keese,12SIR,ENG LIT,DRAMA,SOCIOL'
etc...

And I want to split the entire string into a 2d list. The first set of lists being each line and the second being each element (minus the commas) and also without having the /n at the end of every list.
So for example:


[['762-68-7639', 'Aime', 'Gentzsch', 12ALT, 'ENG LIT', 'MUSIC', 'PSYCHOL']['359-53-2130', 'Marrick', 'Spinelli', '12POL', 'MATHS', 'COMPSCI', 'PHYSICS']['460-96-3787', 'Issac', 'Keese', '12SIR', 'ENG LIT', 'DRAMA', SOCIL]]
Is there an easy way to make both the splits at once or if somebody can demonstrate a possible method to split the list up as how i described.
what have you tried? show your code in python tags, any traceback - in error tags.