Read date from .CSV in native format of yy-mm-dd

조회 수: 8 (최근 30일)
Thomas Kirton
Thomas Kirton 2022년 7월 19일
답변: Stephen23 2022년 7월 19일
Hello,
I am importing data from a .CSV where the native date format is yy-mm-dd. Using functions such as readcell or readmatrix return NaN or Matlab ends up looping because it is having issues with the date format. How can I import this? The formatting of the date is not important, I would just like to have some sort of date stamp for organizational purposes.
Many thanks in advance,
Thomas

답변 (1개)

Stephen23
Stephen23 2022년 7월 19일
As far as I can tell, it is not possible to specify the pivot year when calling READTABLE et al. But you can do it afterwards:
T = readtable('test.csv','Format','%s%f')
T = 2×2 table
timestamp data ____________ ______ {'22-07-19'} 3.1316 {'22-07-20'} 2.7183
T.timestamp = datetime(T.timestamp,'inputFormat','yy-MM-dd','PivotYear',2000)
T = 2×2 table
timestamp data ___________ ______ 19-Jul-2022 3.1316 20-Jul-2022 2.7183

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by