필터 지우기
필터 지우기

How to open .CSV file ?

조회 수: 2 (최근 30일)
Vishnu Dhakad
Vishnu Dhakad 2018년 6월 13일
답변: Walter Roberson 2018년 6월 15일
I want to open CSV file. (please find the attachment)
in the CSV file, I have date and time in the different column but I want to combine in one column. I have read with following code but I getting an error.
fbc = fopen('ABCD.CSV');
BC = textscan(fbc, '"%.f-%3.s-%.f", "%.f:%.f", %.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f,%.f');
fclose(fbc);

답변 (2개)

KSSV
KSSV 2018년 6월 13일
[num,txt,raw] = xlsread('ABCD.csv') ;
  댓글 수: 1
Vishnu Dhakad
Vishnu Dhakad 2018년 6월 15일
편집: Vishnu Dhakad 2018년 6월 15일
Thank you, sir
but time is showing in decimal, how to correct into normal?
I want to use the function fopen and textscan.
Can you explain to me how to use this type of function?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2018년 6월 15일
fmt = ['%{dd-MMM-yy}D%{HH:mm}D', repmat('%f', 1, 50)];
fbc = fopen('ABCD.CSV', 'r', 'n', 'UTF8');
BC = textscan(fbc, fmt, 'Delimiter', ',', 'CollectOutput', 1);
fclose(fbc);
dt = BC{1}+(BC{2}-dateshift(BC{2},'start','day'));
dt.Format = 'default';
numbers = BC{3};

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by