I am taking an input text and a pattern from the user. Text is in the tabular format. Depending on the users choice, I want the code to give me all the columns of the row the user has selected using pattern. Eg. Text:
Name Age Sex Address
ABC 22 Male Bangalore
XYZ 34 Female Hyderabad
Now the user gives input as 'XYZ' and the text given above. I want a code that would fetch me all the results i.e. 34,Female,Hyderabad in a list or in different variables. I tried using group but I am not able to understand how would I use group in this. Since 'XYZ' is given by the user, assumne it to be stored in a variable 'pattern'
csvmodule is ideal for this. IfNameis a unique identifier, then you just need acsv.reader()object and apply{row[0]: row[1:] for row in reader}to it.