how to find specific string out of a list in an excel

2 visualizaciones (últimos 30 días)
file = read('file');
pattern = strcmp('9',file);
row = find(pattern==1);
writetable(row,'sampletable.txt')
  2 comentarios
Walter Roberson
Walter Roberson el 8 de Ag. de 2022
Are you starting with a .csv file or a .xlsx file?
Are there multiple columns in the file? Should only one column be examined for a match? Should the entire row with the match be output? Is it possible that multiple rows will match?
Ihaveaquest
Ihaveaquest el 8 de Ag. de 2022
yes and yes yes yes yes to all .. csv file with 1000lines but theres a column with value 9 and 17 that i need the full like row info
thank you

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Ag. de 2022
data = readtable('FileNameGoesHere');
mask = data{:,ColumnNumberGoesHere} == 9;
subset = data(mask,:);
writetable(subset, 'sampletable.txt');
  2 comentarios
Ihaveaquest
Ihaveaquest el 8 de Ag. de 2022
Editada: Ihaveaquest el 9 de Ag. de 2022
thank you! it works great!
Image Analyst
Image Analyst el 8 de Ag. de 2022
@Juan you again forgot to attach your data file and say what string pattern you're looking for. So that leads me to believe you did not read the Community Guidelines or Tutorial.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by