I want to import only specific Types of variables using readtable.
Afficher commentaires plus anciens
Hello, so I am using 'readtable' to import some text data that I have. I am then using 'table2timetable' to be able to use my data as a time table. The data if have is collected sparatically at different minutes and hours, so I am using
NewData = retime(TimeTableOut,'hourly','mean');
to average the values into a whole hour row.
But I am getting this error.
All variables in input timetables must be numeric, datetime, or duration when synchronizing using 'mean'.
I understood what that meant so I deleted the coumns (variables) of the imported table that contain data that is not of these types. It worked once I did this, but I would like to know if there is a better way to do this so I don't have to go in and delete columns myself every time. I would like to import data columns (variables) that contain only these three types of data. Any help is appreciated! If you need, I can attach my table or text file that I am importing.
3 commentaires
dpb
le 24 Juin 2020
Think be useful to see the text file, yes. Don't fully understand w/o the reason for the message--doesn't seem as though would make a lot of sense to try to average nonnumeric data and don't follow what is in the timetable that doesn't belong -- or why it would be there to start with?
Forrest Ward
le 24 Juin 2020
dpb
le 24 Juin 2020
Presuming these files all follow same format, I'd suggest building an importoptions object from the output of detectImportOptions that contains the selected input variables you want and use it when reading the files. You could possibly have more than one if there are different subsets of variables wanted for particular analyses.
This can be done once and saved in a .mat file and loaded and used for any file of the same structure.
Alternatively, you can just accept what readtable finds and then use isnumeric() on the columns to get rid of the unwanted columns after the fact.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Timetables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!