フィルターのクリア

Help removing columns from csv file

21 ビュー (過去 30 日間)
Jimes Tooper
Jimes Tooper 2011 年 11 月 30 日
Hey all,
I'm new to matlab and need some quick help manipulating csv files. I have giant (1 million rows plus) csv files with 6 columns, and I need to run PSDs on only two of the columns of data. I want to extract the two specific columns of data from the big csv, put them into variables or separate csvs, and use them for calculations. Right now I'm wrestling with textscan because there are headers in these files and some of the columns contain text.
Sample of data:
Ct*0.00127405S A1(g) A2(g) A3(g) SN FCTR
1 0.027 -0.022 0.985 95 41 [Crc OK]
2 0.027 -0.022 0.985 95 42 [Crc OK]
3 0.027 -0.022 0.984 95 43 [Crc OK]
4 0.027 -0.021 0.982 95 44 [Crc OK]
5 0.027 -0.022 0.983 95 45 [Crc OK]
thank you! JT

採用された回答

John
John 2011 年 11 月 30 日
If you want to load in the data and pull out the third and fourth columns (just as an example) I'd do the following:
[num txt raw] = xlsread('Book1.csv');
data = cell2mat(raw(2:end,[3 4]));
csvwrite('test.csv',data)
This will pull the data out and save it into a new csv file, you could also try,
[num txt raw] = xlsread('Book1.csv');
data = num(2:end,[3 4]);
csvwrite('test.csv',data)
If you dont want to mess with cell arrays, hope it helps.
  3 件のコメント
John
John 2011 年 11 月 30 日
Forgot about that, thanks, if youre on mac you might want to try csvread() although this only can only import numerical data (no strings in the file).
John
John 2011 年 11 月 30 日
On a mac you may also be able to use importdata
A = importdata('Book1.csv')
and then index however you like

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by