TextStr = ['timestamp,open,high,low,close,volume', newline, ...
'2019-01-07 14:45:00,102,102.4,103.23,103.00,1955320', newline, ...
'2019-01-07 14:46:00,102.3,102.2,102.6,103.9,267856', newline]
HeaderFmt = '%s%s%s%s%s%s';
DataFmt = '%D%f%f%f%f%f';
Fields = cellfun(@(x) x{1}, textscan(TextStr, HeaderFmt, 1, 'Delimiter', ','), 'un', 0);
Data = textscan(TextStr, DataFmt, 'Headerlines', 1, 'EndOfLine', newline, 'Delimiter', ',');
Table = table(Data{:}, 'VariableNames', Fields);
TextStr = ['timestamp,open,high,low,close,volume', char(10), ...
'2019-01-07 14:45:00,102,102.4,103.23,103.00,1955320', char(10), ...
'2019-01-07 14:46:00,102.3,102.2,102.6,103.9,267856', char(10)]
FID = fopen('temp.csv', 'w');
fprintf(FID, TextStr);
fclose(FID);
Table = readtable('temp.csv');
댓글 수: 6
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657851
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657851
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657858
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657858
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657863
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657863
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657876
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657876
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657883
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657883
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657892
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/438671-how-do-i-convert-a-csv-formatted-string-to-a-table-or-timetable#comment_657892
댓글을 달려면 로그인하십시오.