Created
February 19, 2020 16:29
-
-
Save mattgaidica/4d9cef7da95302b289a7989cf10cbd76 to your computer and use it in GitHub Desktop.
Complete_Pero_Master_1.29.20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| csvPath = "/Users/matt/Documents/MATLAB/Misc/Complete_Pero_Master_1.29.20_dateFMT.csv"; | |
| T = readtable(csvPath); | |
| % augment table | |
| firstCaught = cell(size(T,1),1); | |
| lastCaught = firstCaught; | |
| % new table | |
| new_firstCaught = {}; | |
| new_lastCaught = {}; | |
| new_mouseID = {}; | |
| mouseIDs = unique(T.MouseID); | |
| mouseIDs(strcmp(mouseIDs,'')) = []; % rm empties | |
| for iMouse = 1:numel(mouseIDs) | |
| new_mouseID{iMouse,1} = mouseIDs{iMouse}; | |
| mouseRows = find(strcmp(T.MouseID,mouseIDs{iMouse})); | |
| maxDate = max(T.Date(mouseRows)); | |
| new_lastCaught{iMouse,1} = maxDate; | |
| minDate = min(T.Date(mouseRows)); | |
| new_firstCaught{iMouse,1} = minDate; | |
| for iRow = mouseRows' | |
| firstCaught{iRow,1} = minDate; | |
| lastCaught{iRow,1} = maxDate; | |
| end | |
| end | |
| Tupdated = addvars(T,firstCaught,lastCaught); | |
| Talt = table(new_mouseID,new_firstCaught,new_lastCaught); | |
| writetable(Tupdated,'Complete_Pero_Master_1.29.20_updated_v1.csv'); | |
| writetable(Talt,'Complete_Pero_Master_1.29.20_alternative_v1.csv'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment