Dataline [n1 n2] didn't work

Hello,
i have a csv of 18 000 line I need to import this data from 300 to 17000, i have tried data.dataline = [300 17000] but it returns me an error that Dataline must be a positive intreger , i don't know where this error come from
thanks in advance for your answers
Best regards

5 Comments

please attach your data
and your code
code :
A = uigetfile
data = detectImportOptions(A)
data.Delimiter = ';';
data.VariableNamesLine = 5;
data.DataLine = [300 17960]
T = readtable(A,data, 'ReadVariableNames', true);
accel= T.Acceleration
force = T.Force
my data is so big that even a compressed file can't be attached
my data is a column with a positive and negative values
thanks for your answers
@rimbak it would be helpful to know/have the following
  1. The entire copy-pasted error message.
  2. The version of Matlab you're using
  3. A smaller version of your file that we could run to try to reproduce the error. I'm surprised that a file with 18k lines and with only 1 column of numeric data is very large. Nevertheless, having a representitive sample of the document (ie, lines 300-400) might be helpful.

Sign in to comment.

Answers (1)

Unfortunately in your release, DataLines only permitted a single value, not a range of values.
PerLine = 343;
DataLines = [300 17960]
[filename, filepath] = uigetfile();
if ~ischar(filename); return; end %user cancel
fullname = fullfile(filepath, filename);
fmt = repmat('%f', 1, PerLine);
headerlines = DataLines(1)-1;
numlines = DataLines(2)-DataLines(1)+1;
[fid, msg] = fopen(fullname, 'rt');
if fid < 0;
error('Could not open file because "%s"', msg);
end
data = cell2mat( textscan(fid, fmt, numlines, 'Headerlines', headerlines, 'Delimiter', ';') );
fclose(fid);
You will need to figure out which column is force and which is acceleration.
Note: if you only need selected columns, then the reading can be made more efficient by manipulating the computed fmt

Products

Release

R2016b

Asked:

on 15 Mar 2022

Answered:

on 17 Mar 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!