I'm trying to extract the elements of a list to turn it into a CSV file. I have a long list containing string elements. Example:
print(list_x[0])
['NAME\tGill Pizza Ltd v Labour Inspector', 'JUDGE(S)\tWilliam Young, Ellen France & Williams JJ', 'COURT\tSupreme Court', 'FILE NUMBER\tSC 67-2021', 'JUDG DATE\t12 August 2021', 'CITATION\t[2021] NZSC 97', 'FULL TEXT\t PDF judgment', 'PARTIES\tGill Pizza Ltd (First Applicant), Sandeep Singh (Second Applicant), Jatinder Singh (Third Applicant/Fourth Applicant), Mandeep Singh (Fourth Applicant/Third Applicant), A Labour Inspector (Ministry of Business, Innovation and Employment) (Respondent), Malotia Ltd (First Applicant)', 'STATUTES\tEmployment Relations Act 2000 s6(5), s228(1)', 'CASES CITED\tA Labour Inspector (Ministry of Business, Innovation and Employment) v Gill Pizza Ltd [2021] NZCA 192', 'REPRESENTATION\tGG Ballara, SP Radcliffe, JC Catran, HTN Fong', 'PAGES\t2 p', 'LOCATION\tNew Zealand Law Society Library', 'DATE ADDED\tAugust 19, 2021']
Is it possible to do something like:
name_list = []
file_number_list = []
subject_list = []
held_list = []
pages_list = []
date_list = []
for i in range(len(list_x)):
if list_x[i].startswith('NAME'):
name_list.append(list_x[i])
elif list_x[i].startswith('FILE NUMBER'):
file_number_list .append(list_x[i])
elif list_x[i].startswith('SUBJECT'):
subject_list .append(list_x[i])
elif list_x[i].startswith('HELD'):
held_list .append(list_x[i])
elif list_x[i].startswith('PAGES'):
pages_list .append(list_x[i])
elif list_x[i].startswith('DATE ADDED'):
date_list .append(list_x[i])
Any help is appreciated. Cheers.