I am trying to do something that seems straightforward, but is giving me endless trouble.
What I would like to do:
1 for i in nameList 2 Iterate through each row of aggregatedCSV 3 If i is a partial match in current row, append that entire row to a new name-specific CSV (repeat steps 2 and 3 for remaining i in nameList) nameList = ['Jon', 'Bob', 'Tim']
aggregatedCSV = [ [1, '3', 'Bob85'], [2, 'Jon52', '8'], ['Bob1', '14', 3], ['Tim95', 8, '6'], ['8', 11, 'Tim48'], [10, 'Jon11', '44'], [26, '21', 'Jon90'], [99, '23', 'Bob19'], [7, '24', 'Tim82'] ] The desired output would ultimately be three new CSV files but, to keep it simple for here, I am trying to get something like:
JonList = [[2, 'Jon52', '8'], [10, 'Jon11', '44'],[26, '21', 'Jon90']]
BobList = [[1, '3', 'Bob85'], ['Bob1', '14', 3], [99, '23', 'Bob19']]
TimList = [['Tim95', 8, '6'], ['8', 11, 'Tim48'], [7, '24', 'Tim82']]
Although I have manually created nameList for this example, I will be reading from csv files that will have an unknown number of rows, with an unknown number of values per row.
Any help is appreciated.