read data from csv file & fast processing
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
i have a data like which is read from csv file like
10;20;2;3;45;56;87;56;988;434;10;20;2;3;45;56;87;56;988;434
i have 9lakhs of data like this what is best way to separate by ; & form a matrix
because now it is consuming to much of time
Thanks in advance
12 Commenti
  Jan
      
      
 il 27 Nov 2012
				@shaz: Although it looks obvious, that you neither read the comments nor care about them: Please stop using the term "lakh" without any further explanations, because it is not part of the English language such that it might confuse the readers. It is very friendly that Per explained this, but this has been your your turn actually.
Can you imagine the effects, when you do not care about questions for clarifications?
Risposta accettata
  Jan
      
      
 il 7 Nov 2012
        
      Modificato: Jan
      
      
 il 8 Nov 2012
  
      fid = fopen(FileName, 'r');
if fid == -1, error('Cannot open file!'); end
header = fgetl(fid);     % Read header line
pos    = ftell(fid);     % Store position [EDITED: fseek -> ftell]
line1  = fgetl(fid);     % first data line
data   = sscanf(line1, '%g;', Inf);
ncol   = length(data);
fmt    = repmat('%g; ', 1, ncol);
fseek(fid, pos, 'bof');  % Restore file position
data   = fscanf(fid, fmt, Inf);
data   = transpose(reshape(data, ncol, []));
fclose(fid);
Please check the reshape and transpose, if it satisfies your needs.
3 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Data Import and Analysis in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



