Importing ISO 8601 Formatted CSV Dates into Matlab R2014b

11 views (last 30 days)
I am trying to import a CSV file with ISO 8601 formatted dates with Matlab R2014b. I am using the CSV import wizard, and am needing to use the custom date formatter, as the ISO 8601 date format is not built into Matlab.
However, Matlab never recognises the date/time data as date/time data. Can anyone resolve this? The documentation doesn't say anything about how items that are not part of the date format (e.g. the 'T') are parsed.
Picking a string directly for conversion works ok.
>> datenum('"2008-01-01T00:00:00+13:00"', '"yyyy-MM-ddThh:mm:ssZZZZZ"')
ans =
7.3338e+05
But the same conversion does not work in the CSV import wizard, as shown in the screenshot below.
Any particular reason why it works in the command line but not in the import wizard?
Note: This question also appears on Stack Overflow, as question 31977991. Stack Overflow Link.

Answers (1)

per isakson
per isakson on 13 Aug 2015
Edited: per isakson on 14 Aug 2015
It's a mess!
The old functions, datenem, etc., are not updated to honor the new datetime Properties (e.g. Time Zone Offset Formats). And the old functions don't always throw appropriate messages.
"... directly for conversion works ok" &nbsp Did you check the result?
>> datestr( datenum('"2008-01-01T00:00:00+13:00"', '"yyyy-MM-ddThh:mm:ssZZZZZ"'), 31 )
ans =
2007-11-30 12:01:00
>> version
ans =
8.2.0.701 (R2013b)
datetime &nbsp was officially introduced in R2014b
  3 Comments
per isakson
per isakson on 14 Aug 2015
Edited: per isakson on 14 Aug 2015
For the time being we have to be aware that
  • Matlab have old and new functions to handle date and time
  • the date and time formats of the new and the old differ
  • the old functions doesn't throw errors for new formats, which they don't interpret correctly
Conclusion: The user must be careful to adhere to the correct parts of the documentation.
Lets hope this "issue" is fixed in R2015a.

Sign in to comment.

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!