Need to copy Channel field data from a specific data range (e.g. January 2024) from field 6 of channel A to field 1 of channel B
Edgar
on 12 Feb 2024
Latest activity Reply by Christopher Stapels
on 13 Feb 2024
I need to copy Channel field data from a specific data range (e.g. January 2024) from field 6 of channel A(see sample attached) to field 1 of channel B.
I have tried to adopt the Template "Get data from private channel" in the Matlab analysis area of Thingspeak. The last data can be copied according the sample, but I cannot manage to copy the complete datarange. My channel field contains half empty data in field 6, because I have posted data asynchrously from 2 devices to 1 channel up to now.
Any advice for proper Matlab code sample or the like is welcome!
5 Comments
Time DescendingThanks for prompt reply!
I already passed the documentation for thingSpeakRead and thingSpeakWrite:
Obviously there is no problem reading the January array from below thingSpeakRead command.
But the thingSpeakWrite end in :
"Error using Copy Data from one channel to another Second input must be either a named parameter or data specified as numeric scalars or arrays or cell arrays or tables."
Can you help me to adapt the thingSpeakWrite command to write the January Data Array in the writeChannelID ?
%% Read Data %%
readField = 6; % Specify the field to read
[data,timestamps,channelInfo] = thingSpeakRead(readChannelID, 'Fields', readField, 'ReadKey', readAPIKey, DateRange=[datetime(2024,1,1,00,00,01),datetime(2024,1,31,23,59,52)]);
%% Write Data %%
writeField = 1; % Specify the field to write
% Write the table to the new channel
thingSpeakWrite(writeChannelID, data, 'TimeStamp', timestamps, 'Fields', writeField, 'WriteKey', writeAPIKey);
Attached the source channel data extract and the adopted basic script for coping the last data only.
Any modification to copy complete datarange (e.g. January data) from source to target channel very welcome!
Thanks in advance!
Can you put your code inline or try the attachment again? It did not come through.
Sign in to participate