Transpose column from .csv file

조회 수: 19 (최근 30일)
Bernoulli Lizard
Bernoulli Lizard 2012년 10월 22일
How can I transpose a column that is read from a .csv file? Currently I am reading the column, transposing it, and reprinting it. However, all of the numbers are crunched together into one cell. When I transpose, I need to have commas between each of my columns (or what used to be the end of a row, before the transpose took place).
-- This is what I am trying, but it does not work
C1 = dlmread(strcat(GlotaranFileName,'.csv'), ',', [0 1 lineCount 1]);
fprintf(fid, '%d', C1'); % write the relevent data to the file
thanks

채택된 답변

Walter Roberson
Walter Roberson 2012년 10월 22일
fprintf(fid, '%d,', C1(1:end-1)'); %notice the comma after %d
fprintf(fid, '%d\n', C1(end));
  댓글 수: 1
Bernoulli Lizard
Bernoulli Lizard 2012년 10월 22일
Of course! Thank you, that seems obvious now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by