Ihre Datei sieht aus wie eine große CSV für diese Matlab mit dem Data Store
https://es.mathworks.com/help/matlab/import_export/what-is-a-datastore.html
eine gute Umsetzung hat und hat diese Werkzeuge für die Arbeit mit großen Dateien:
https://es.mathworks.com/help/matlab/large-files-and-big-data.html
Und schauen Sie auch zur Arbeit with tables in matlab
In yo ur Fall können Sie so etwas wie dies funktioniert:
die Beispieldatei airlinessmall.csv (123.524 Zeilen)
Year,Month,DayofMonth,DayOfWeek,DepTime,CRSDepTime,ArrTime,CRSArrTime,UniqueCarrier,FlightNum,TailNum,ActualElapsedTime,CRSElapsedTime,AirTime,ArrDelay,DepDelay,Origin,Dest,Distance,TaxiIn,TaxiOut,Cancelled,CancellationCode,Diverted,CarrierDelay,WeatherDelay,NASDelay,SecurityDelay,LateAircraftDelay
1987,10,21,3,642,630,735,727,PS,1503,NA,53,57,NA,8,12,LAX,SJC,308,NA,NA,0,NA,0,NA,NA,NA,NA,NA
1987,10,26,1,1021,1020,1124,1116,PS,1550,NA,63,56,NA,8,1,SJC,BUR,296,NA,NA,0,NA,0,NA,NA,NA,NA,NA
1987,10,23,5,2055,2035,2218,2157,PS,1589,NA,83,82,NA,21,20,SAN,SMF,480,NA,NA,0,NA,0,NA,NA,NA,NA,NA
1987,10,23,5,1332,1320,1431,1418,PS,1655,NA,59,58,NA,13,12,BUR,SJC,296,NA,NA,0,NA,0,NA,NA,NA,NA,NA
1987,10,22,4,629,630,746,742,PS,1702,NA,77,72,NA,4,-1,SMF,LAX,373,NA,NA,0,NA,0,NA,NA,NA,NA,NA
1987,10,28,3,1446,1343,1547,1448,PS,1729,NA,61,65,NA,59,63,LAX,SJC,308,NA,NA,0,NA,0,NA,NA,NA,NA,NA
1987,10,8,4,928,930,1052,1049,PS,1763,NA,84,79,NA,3,-2,SAN,SFO,447,NA,NA,0,NA,0,NA,NA,NA,NA,NA
1987,10,10,6,859,900,1134,1123,PS,1800,NA,155,143,NA,11,-1,SEA,LAX,954,NA,NA,0,NA,0,NA,NA,NA,NA,NA
...
Mit tou Datenspeicher können als Tabellen mit Daten arbeiten und die Variablen, die Sie benötigen, so zum Beispiel erhalten zu erhalten de der Ankunft Verzögerungen bedeuten:
>> ds = datastore('airlinesmall.csv','TreatAsMissing','NA');
>> ds.MissingValue = 0;
>> ds.SelectedVariableNames = 'ArrDelay';
>> data = preview(ds)
data =
ArrDelay
________
8
8
21
13
4
59
3
11
>> data % this is a table
data =
ArrDelay
________
8
8
21
13
4
59
3
11
>> sums = [];
counts = [];
while hasdata(ds)
T = read(ds); % this is a table, but this is not all loaded in memory
sums(end+1) = sum(T.ArrDelay);
counts(end+1) = length(T.ArrDelay);
end
>> avgArrivalDelay = sum(sums)/sum(counts)
avgArrivalDelay =
6.9670
Lassen Sie uns die Arbeit mit Ihrer Probe. überprüfen Sie diese Datei:
sample.csv
TYPE OF FAILURE, START DATE, START TIME, DURATION, LOCALIZATION, WORKING TEAM, SHIFT
failure 1, 06/01/2017, 12/13/20, 300, Area 1, A, morning
failure 2, 06/01/2017, 12/13/20, 300, Area 1, A, night
failure 3, 06/01/2017, 12/13/20, 400, Area 1, A, afternoon
failure 1, 08/01/2017, 12/13/20, 300, Area 1, A, morning
failure 2, 09/01/2017, 12/13/20, 300, Area 1, A, morning
failure 3, 09/01/2017, 12/13/20, 300, Area 1, A, night
failure 3, 09/01/2017, 14/13/20, 200, Area 1, A, morning
failure 1, 10/01/2017, 12/13/20, 300, Area 1, A, morning
failure 1, 12/01/2017, 12/13/20, 300, Area 1, A, afternoon
failure 2, 12/01/2017, 12/13/20, 500, Area 1, A, morning
failure 1, 14/01/2017, 12/13/20, 300, Area 1, A, night
Sie, dass der Ausfall 1 sehen kann alle zwei Tage mal sehen, ist dies:
>> ds = tabularTextDatastore('sample.csv')
Warning: Variable names were modified to make them valid MATLAB identifiers.
ds =
TabularTextDatastore with properties:
Files: {
'/home/anquegi/learn/matlab/stackoverflow/sample.csv'
}
FileEncoding: 'UTF-8'
ReadVariableNames: true
VariableNames: {'TYPEOFFAILURE', 'STARTDATE', 'STARTTIME' ... and 4 more}
Text Format Properties:
NumHeaderLines: 0
Delimiter: ','
RowDelimiter: '\r\n'
TreatAsMissing: ''
MissingValue: NaN
Advanced Text Format Properties:
TextscanFormats: {'%q', '%q', '%q' ... and 4 more}
ExponentCharacters: 'eEdD'
CommentStyle: ''
Whitespace: ' \b\t'
MultipleDelimitersAsOne: false
Properties that control the table returned by preview, read, readall:
SelectedVariableNames: {'TYPEOFFAILURE', 'STARTDATE', 'STARTTIME' ... and 4 more}
SelectedFormats: {'%q', '%q', '%q' ... and 4 more}
ReadSize: 20000 rows
>> ds.SelectedVariableNames = {'TYPEOFFAILURE', 'STARTDATE', 'STARTTIME', 'DURATION', 'LOCALIZATION', 'WORKINGTEAM', 'SHIFT'}
ds =
TabularTextDatastore with properties:
Files: {
'/home/anquegi/learn/matlab/stackoverflow/sample.csv'
}
FileEncoding: 'UTF-8'
ReadVariableNames: true
VariableNames: {'TYPEOFFAILURE', 'STARTDATE', 'STARTTIME' ... and 4 more}
Text Format Properties:
NumHeaderLines: 0
Delimiter: ','
RowDelimiter: '\r\n'
TreatAsMissing: ''
MissingValue: NaN
Advanced Text Format Properties:
TextscanFormats: {'%q', '%q', '%q' ... and 4 more}
ExponentCharacters: 'eEdD'
CommentStyle: ''
Whitespace: ' \b\t'
MultipleDelimitersAsOne: false
Properties that control the table returned by preview, read, readall:
SelectedVariableNames: {'TYPEOFFAILURE', 'STARTDATE', 'STARTTIME' ... and 4 more}
SelectedFormats: {'%q', '%q', '%q' ... and 4 more}
ReadSize: 20000 rows
>> reset(ds)
accum = [];
while hasdata(ds)
T = read(ds);
accum = datetime(T(strcmp(T.TYPEOFFAILURE,'failure 1'),:).STARTDATE, 'InputFormat','dd/MM/yyyy');
mean(diff(accum))
end
ans =
48:00:00
% Genau alle 48 Stunden, und dann können Sie versuchen, mit jeder Sache, die Sie wollen
Vielen Dank für einen guten Hinweis :). Ich werde auf jeden Fall Data Store für Matlab betrachten. Jedoch habe ich auch nach dem algorithmischen Teil meiner Frage gesucht. Kannst du mir auch etwas dazu sagen?:) –
Natürlich werde ich versuchen, könnten Sie eine Beispieldatei einfügen, 5-6 Zeilen und das Beispiel für diese Datei angewendet – anquegi
Bearbeitet, um mit Ihren Beispieldaten zu arbeiten, wenn es hilft, upvote oder Geschenk vcorrect Antwort zu vergessen – anquegi