あなたは私はあなたがDataStoreを使用しても、あなたのケースdatastore
のため残念ながらtableの
と連携する方法を学習することをお勧めしますCSVファイルのbigdataセットを分析するためにMATLABを使用している場合、読み取り専用である(限り
Batting.csv::私は)知っているが、あなたはこのように進めることができますように、我々はこのcsvがあるとしましょう
ds = tabularTextDatastore('Batting.csv');
>> ds.ReadSize = 1
ds =
TabularTextDatastore with properties:
Files: {
'/Users/toni/Documents/MATLAB/Batting.csv'
}
FileEncoding: 'UTF-8'
ReadVariableNames: true
VariableNames: {'playerID', 'yearID', 'stint' ... and 19 more}
Text Format Properties:
NumHeaderLines: 0
Delimiter: ','
RowDelimiter: '\r\n'
TreatAsMissing: ''
MissingValue: NaN
Advanced Text Format Properties:
TextscanFormats: {'%q', '%f', '%f' ... and 19 more}
TextType: 'char'
ExponentCharacters: 'eEdD'
CommentStyle: ''
Whitespace: ' \b\t'
MultipleDelimitersAsOne: false
Properties that control the table returned by preview, read, readall:
SelectedVariableNames: {'playerID', 'yearID', 'stint' ... and 19 more}
SelectedFormats: {'%q', '%f', '%f' ... and 19 more}
ReadSize: 1 rows
あなたがコンテンツをプレビューすることができます
のDataTableでの作業
>> preview(ds)
ans =
playerID yearID stint teamID lgID G AB R H x2B x3B HR RBI SB CS BB SO IBB HBP SH SF GIDP
___________ ______ _____ ______ ____ __ ___ __ __ ___ ___ __ ___ __ __ __ __ ___ ___ ___ ___ ____
'abercda01' 1871 1 'TRO' 'NA' 1 4 0 0 0 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN
'addybo01' 1871 1 'RC1' 'NA' 25 118 30 32 6 0 0 13 8 1 4 0 NaN NaN NaN NaN NaN
'allisar01' 1871 1 'CL1' 'NA' 29 137 28 40 4 5 0 19 3 1 2 5 NaN NaN NaN NaN NaN
'allisdo01' 1871 1 'WS3' 'NA' 27 133 28 44 10 2 2 27 1 1 0 2 NaN NaN NaN NaN NaN
'ansonca01' 1871 1 'RC1' 'NA' 25 120 29 39 11 3 0 16 6 2 2 1 NaN NaN NaN NaN NaN
'armstbo01' 1871 1 'FW1' 'NA' 12 49 9 11 2 1 0 5 0 1 0 1 NaN NaN NaN NaN NaN
'barkeal01' 1871 1 'RC1' 'NA' 1 4 0 1 0 0 0 2 0 0 1 0 NaN NaN NaN NaN NaN
'barnero01' 1871 1 'BS1' 'NA' 31 157 66 63 10 9 0 34 11
:
>> reset(ds)
>> while hasdata(ds)
T = read(ds);
disp(T(strcmp(T.teamID,'RC1'),:));
end
playerID yearID stint teamID lgID G AB R H x2B x3B HR RBI SB CS BB SO IBB HBP SH SF GIDP
___________ ______ _____ ______ ____ __ ___ __ __ ___ ___ __ ___ __ __ __ __ ___ ___ ___ ___ ____
'addybo01' 1871 1 'RC1' 'NA' 25 118 30 32 6 0 0 13 8 1 4 0 NaN NaN NaN NaN NaN
'ansonca01' 1871 1 'RC1' 'NA' 25 120 29 39 11 3 0 16 6 2 2 1 NaN NaN NaN NaN NaN
'barkeal01' 1871 1 'RC1' 'NA' 1 4 0 1 0 0 0 2 0 0 1 0 NaN NaN NaN NaN NaN
'birdge01' 1871 1 'RC1' 'NA' 25 106 19 28 2 5 0 13 1 0 3 2 NaN NaN NaN NaN NaN
'fishech01' 1871 1 'RC1' 'NA' 25 123 24 28 3 3 1 22 1 2 3 1 NaN NaN NaN NaN NaN
'fulmech01' 1871 1 'RC1' 'NA' 16 63 11 17 1 3 0 3 0 0 5 1 NaN NaN NaN NaN NaN
'hamra01' 1871 1 'RC1' 'NA' 25 113 25 28 4 0 0 12 6 2 1 7 NaN NaN NaN NaN NaN
'hastisc01' 1871 1 'RC1' 'NA' 25 118 27 30 6 4 0 20 11 2 2 4 NaN NaN NaN NaN NaN
'mackde01' 1871 1 'RC1' 'NA' 25 122 34 30 7 1 0 17 12 0 8 7 NaN NaN NaN NaN NaN
'sagerpo01' 1871 1 'RC1' 'NA' 8 39 9 11 0 0 0 5 5 1 2 2 NaN NaN NaN NaN NaN
'stirega01' 1871 1 'RC1' 'NA' 25 110 23 30 4 6 2 24 3 0 7 5 NaN NaN NaN NaN NaN
、最終的にはあなたの仕事を得るための汚い方法:
>> reset(ds)
>> T = readall(ds);
>> writetable(T(strcmp(T.teamID,'RC1'),:),'mydata.txt');
がMYDATAと呼ばれるファイルを取得.txt
内容:
playerID,yearID,stint,teamID,lgID,G,AB,R,H,x2B,x3B,HR,RBI,SB,CS,BB,SO,IBB,HBP,SH,SF,GIDP
addybo01,1871,1,RC1,NA,25,118,30,32,6,0,0,13,8,1,4,0,NaN,NaN,NaN,NaN,NaN
ansonca01,1871,1,RC1,NA,25,120,29,39,11,3,0,16,6,2,2,1,NaN,NaN,NaN,NaN,NaN
barkeal01,1871,1,RC1,NA,1,4,0,1,0,0,0,2,0,0,1,0,NaN,NaN,NaN,NaN,NaN
birdge01,1871,1,RC1,NA,25,106,19,28,2,5,0,13,1,0,3,2,NaN,NaN,NaN,NaN,NaN
fishech01,1871,1,RC1,NA,25,123,24,28,3,3,1,22,1,2,3,1,NaN,NaN,NaN,NaN,NaN
fulmech01,1871,1,RC1,NA,16,63,11,17,1,3,0,3,0,0,5,1,NaN,NaN,NaN,NaN,NaN
hamra01,1871,1,RC1,NA,25,113,25,28,4,0,0,12,6,2,1,7,NaN,NaN,NaN,NaN,NaN
hastisc01,1871,1,RC1,NA,25,118,27,30,6,4,0,20,11,2,2,4,NaN,NaN,NaN,NaN,NaN
mackde01,1871,1,RC1,NA,25,122,34,30,7,1,0,17,12,0,8,7,NaN,NaN,NaN,NaN,NaN
sagerpo01,1871,1,RC1,NA,8,39,9,11,0,0,0,5,5,1,2,2,NaN,NaN,NaN,NaN,NaN
stirega01,1871,1,RC1,NA,25,110,23,30,4,6,2,24,3,0,7,5,NaN,NaN,NaN,NaN,NaN
このトピックに慣れているわけではありませんが、私はあなたに 'fopen( 'file2.csv'、 'a')'を使ってデータを追加したいと思うかもしれません。 5番目の魅力を編集しますか? – Durkee