textscan gives me wrong number of lines

1 visualización (últimos 30 días)
Sumin Kim
Sumin Kim el 12 de Nov. de 2018
Editada: dpb el 13 de Nov. de 2018
I have a file names inputR_revised.tsv at https://www.dropbox.com/s/vtby4027rvprhga/inputR_revised.tsv?dl=0 In matlab, I typed
fid=fopen('BMC3C/example/inputR_revised.tsv','r')
covTable = textscan(fid,['%s',repmat('%.8n',[1,20])],'HeaderLines',1);
I get covTable{1,1} of size 41699 times 1. However when I type the following at terminal
wc -l inputR_revised.tsv
I get 41677. Why does it differ? I have used sed and cut to modify the original file to get inputR_revised.tsv. Is this the reason?
Is there a way to fix this?

Respuestas (1)

dpb
dpb el 12 de Nov. de 2018
In
covTable = textscan(fid,['%s',repmat('%.8n',[1,20])],'HeaderLines',1);
you set the 'HeaderLines' option to True (1) so the first line is being ignored by textscan and read as a header, not data. If it is actually data instead, then
covTable = textscan(fid,['%s',repmat('%.8n',[1,20])],'HeaderLines',0);
will fix that (or error if it really is a header, one; we can't tell whether it is or isn't).
  2 comentarios
Sumin Kim
Sumin Kim el 12 de Nov. de 2018
Thank you. But there is an header. And the number of lines differ by 22
dpb
dpb el 13 de Nov. de 2018
Attach the file here...

Iniciar sesión para comentar.

Categorías

Más información sobre Large Files and Big Data en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by