readtable is not reading the time 12:00:00 AM?
31 次查看（过去 30 天）
I am using 'readtable' to read an excel file. The first column of the file contains date and time in 'mm/dd/yyyy HH:MM:SS PM' format. The probelm is the following:
The readtable skips the time if the entry is '5/7/2018 12:00:00 AM'. I want to read entire date-time string. is it possibel to do it using the readtable?
I am using the following code to invoke the readtable:
Note: the readtable is able to read other time-entries perfectly; the above time-entry is 1427th row in the file, including header.
Walter Roberson 2020-2-17
Your input format specification should be 'MM/dd/yyyy hh:mm:ss a' to read that.
m is minutes not month
H is only for 24 hour clock
M is for month not minutes
S is for fractions of a second
PM is the wrong specifier for AM/PM
Motasem Mustafa 2020-10-19
I have the same issue.
I have a data from a datalogger and when I am using a code to separate the year,month,day, and time from the data, it gives me an error. When I skip the row of the time 00:00:00, the code works.
When openeing the workspapce it shows that 00:00:00 is empty as shown in the screenshot below.
I am still struggling with the code and did not solve it.
Yutaka Yamada 2021-5-24
编辑：Yutaka Yamada 2021-5-24
Recentely I've tried similar thing.
Please try below code.
opts = detectImportOptions('readTime.xlsx');
opts.VariableTypes = 'datetime';
opts.VariableOptions.DatetimeFormat = 'mm/dd/yyyy HH:mm:ss a';
T = readtable('readTime.xlsx', opts);
I've attached the Excel file that I've used for the test.
Motasem Mustafa 2021-9-1
Assalm Alykom Mohammad Khairi,
Kindly find the below code that worked for me last year and kindly find the linke to the answer.
All the best,
The new code that worked .
Thanks @ Walter Roberson
data = readtable('Book_new.xlsx','Range','A1:A60','ReadVariableNames',false);
A = table2array(data);