Hello,
I have a question. How to open .SRT data file. ? I have columns and rows in this file.
I tried fopen or readtable but it is no use.
Could you help me?

댓글 수: 4

Rik
Rik 2020년 12월 5일
I only know srt as a subtitle format, which I a plain text format. Do you have a description of the format?
Ivan Mich
Ivan Mich 2020년 12월 5일
I open this file with a pad, and I see that this file has 8 columns and 1000 rows. Some columns have text and some numbers.
Rik
Rik 2020년 12월 5일
You will have to post an example if you want help. What have you tried so far yourself? You can start by reading the file to a Matlab variable as text. What would be your next step?
Ivan Mich
Ivan Mich 2020년 12월 5일
Each line has:
' 19 Vladimir 120 69 52 144 18 25 '
I am using the command to read each line.
SRT=regexp(fileread('test.SRT'), '\r?\n', 'split') .';
My question is how to separate each column? I mena how to separate each element of the row?

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 12월 5일

0 개 추천

Without the actual file, we're only guessing. With that in mind, I'd use readtable. It can handle multiple data types, and will split each value into its own column in the table. See how to access data in a table here.
SRT=readtable('test.SRT');
You can find additional options here.

댓글 수: 5

Ivan Mich
Ivan Mich 2020년 12월 5일
As I mentioned, I have tried readtable and it is no use.
command window shows me:
File extension '.SRT' is not recognized. Use 'FileType' to specify the type to read
Cris LaPierre
Cris LaPierre 2020년 12월 5일
Share your file. Attach it using the paperclip icon.
Cris LaPierre
Cris LaPierre 2020년 12월 5일
편집: Cris LaPierre 2020년 12월 5일
I created an SRT file using the snippet you shared above. I saw the same error message, but it tells you what to do in order to use readtable on an unrecognized file type. Doing so loads my sample file as expected.
SRT = readtable("test.SRT","FileType","text")
Ivan Mich
Ivan Mich 2020년 12월 6일
Still not working. My command window shows:
Error using readtable (line 216)
Reading failed at line 6. All lines of a text file must have the same number of delimiters. Line 6
has 6 delimiters, while preceding lines have 8.
Note: readtable detected the following parameters:
'Delimiter', '\t ', 'MultipleDelimsAsOne', true, 'HeaderLines', 4, 'ReadVariableNames', false,
'Format', '%f%q%q%f%f%f%f%f%f'
Error in Untitled (line 8)
SRT = readtable("test.SRT","FileType","text")
Cris LaPierre
Cris LaPierre 2020년 12월 6일
Attach the file or we can't do much more to help you.

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

카테고리

질문:

2020년 12월 5일

댓글:

2020년 12월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by