Export Timetable data to Excel
이전 댓글 표시
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
Stephen23
2024년 9월 27일
Using WRITETIMETABLE is a better approach than converting to table and then using WRITETABLE.
채택된 답변
추가 답변 (1개)
Jaimin
2024년 9월 27일
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
chris weedon
2024년 9월 27일
Jaimin
2024년 9월 27일
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
2024년 9월 27일
"Where does the excel file end up??"
In C:\Users\chris\Downloads, if that is the location you told it to use.
카테고리
도움말 센터 및 File Exchange에서 Prepare and Analyze Data에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!