Python Forum
Splitting String into 2d list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Splitting String into 2d list
#1
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.
Reply
#2
what have you tried? show your code in python tags, any traceback - in error tags.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
This might be helpful....
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  splitting file into multiple files by searching for string AlphaInc 2 816 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  Splitting strings in list of strings jesse68 3 1,704 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Splitting a string twice bazcurtis 2 5,466 Mar-09-2020, 02:54 PM
Last Post: perfringo
  splitting a string with 2 different delimiters Skaperen 4 2,650 Dec-30-2019, 04:49 AM
Last Post: BamBi25
  splitting numeric list based on condition python_newbie09 7 9,281 May-27-2019, 03:58 PM
Last Post: python_newbie09
  I converted string to 'list', but it doesn't look like a list! mrapple2020 3 3,202 Apr-07-2019, 02:34 PM
Last Post: mrapple2020
  Need help | splitting list into list Vinci141 3 2,551 Mar-13-2019, 09:09 PM
Last Post: Vinci141
  Strange behaviour while splitting string? naknak12 2 2,549 Feb-18-2019, 01:57 PM
Last Post: naknak12
  some ideas for intelligent list splitting? wardancer84 4 3,180 Nov-20-2018, 02:47 PM
Last Post: DeaD_EyE
  Create Alert if string from list appears on other list javalava 1 2,479 Sep-17-2018, 02:44 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020