Export Timetable data to Excel
Mostrar comentarios más antiguos
I have a lot of rainfall data which has been uploaded to thingspeak. I want to download some of that data and analyse it in Excel. I was hoping to use the MATLab analysis to do this.
Bearing in mind I am fairly new to this and programming isn't my thing.
I was hoping to use the following code which as far as I understand extracts the data in TimeTable format and then use the writetimetable function to create an Excel spreadsheet. When I run it it extracts the data and displays it as I want without error but I don't know what happens to the xlsx file.
I'm probably missing something
readChannelID = ******;
readAPIKey = '******';
RainFieldID = 1;
RainFall = thingSpeakRead(readChannelID,'Fields',RainFieldID,'NumDays',7,'ReadKey',readAPIKey,OutputFormat='TimeTable');
display(RainFall,'Rainfall');
writetimetable(RainFall,'TT.xlsx')
1 comentario
Stephen23
el 27 de Sept. de 2024
Using WRITETIMETABLE is a better approach than converting to table and then using WRITETABLE.
Respuesta aceptada
Más respuestas (1)
Jaimin
el 27 de Sept. de 2024
Since I don't have API credentials, I am unable to reproduce the issue. However, I do have a workaround that you might try.
You can convert the “timetable” data to a “table” format using the “timetable2table” function. After that, you can store the table data in an Excel format using the “writetable” function..
Please refer following code snippet for better understanding.
% Convert the timetable to a table
RainFallTable = timetable2table(RainFall);
% Write the table to an Excel file
writetable(RainFallTable, 'TT.xlsx');
Refer following MathWorks documentation for more information on “timetable2table” function
Refer following MathWorks documentation for more information on “writetable” function
I hope this will be helpful.
3 comentarios
chris weedon
el 27 de Sept. de 2024
Jaimin
el 27 de Sept. de 2024
Modify the line from "writetable(RainFallTable,'C:\Users\chris\Downloads\TT.xlsx');" to "writetable(RainFallTable, 'TT.xlsx');". After execution, type the "pwd" command in the Command Window. Navigate to the path displayed as the output, and you will find the "TT.xlsx" file there.
Stephen23
el 27 de Sept. de 2024
"Where does the excel file end up??"
In C:\Users\chris\Downloads, if that is the location you told it to use.
Categorías
Más información sobre Prepare and Analyze Data en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!