MATLAB Answers

1

how can I use the clipboard function to directely save this string array on workspace WITHOUT OPENING THE IMPORT WIZARD

Asked by Amine ELMOUATAMID on 17 Apr 2019
Latest activity Commented on by Amine ELMOUATAMID on 17 Apr 2019

  6 Comments

does the code montion the first part of importing data from the clipboard to import tool or just the part of importing data from import tool to workspace?
Doc says:
data = clipboard('pastespecial') imports the clipboard contents into an array using uiimport
I solve the problem
actually uiimport creat a temprary text file and paste on it the data from clipboard in one line.
then the code that generated by import tool changes the data from that line( of text file) to a specific dataArray.
I add this function to the code ( txt=clipboard('paste');) txt is a 1*1 ( like the line of temrary text file)
delimiter = '\t';
%% Format for each line of text:
% column1: text (%s)
% column2: text (%s)
% column3: text (%s)
% column4: text (%s)
% column5: text (%s)
% column6: text (%s)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%s%s%s%s%s%s%[^\n\r]';
%% Read columns of data according to the format.
txt = clipboard('paste');
dataArray = textscan(txt, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'ReturnOnError', false);
%% Create output variable
DATA = [dataArray{1:end-1}];
%% Clear temporary variables
clearvars delimiter formatSpec dataArray txt ;
thank you all for your help

Sign in to comment.

Tags

Products

0 Answers