Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to add new rows to text file with missing data?

1 visualización (últimos 30 días)
Cameron Spooner
Cameron Spooner el 4 de Jul. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have a txt file containing 4 tab delineated columns that are missing rows, like;
1, x, y, z
2, x, y, z
5, x, y, z
I am trying to write a script that will add the missing rows with the correct missing integer in the first column and and assign a 0 value to the other 3 columns, like;
1, x, y, z
2, x, y, z
3, 0, 0, 0
4, 0, 0, 0
5, x, y, z
What would be the easiest way to go about doing this?
  2 comentarios
per isakson
per isakson el 4 de Jul. de 2016
Does the entire file fit comfortably in memory (RAM)?

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Jul. de 2016
s=importdata('fic.txt')
out=zeros(s(end,1),4)
out(s(:,1),:)=s

La pregunta está cerrada.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by