how to read .txt file having the following format.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have text file attached, how can I read it like a table in MATLAB?
[{"ID":1,"Column_A":"red","Column_B":"apple","Column_C":0},{"ID":2,"Column_A":"orange","Column_B":"orange","Column_C":1},{"ID":2,"Column_A":"green","Column_B":"grapes","Column_C":3},{"ID":3,"Column_A":"purple","Column_B":"onion","Column_C":4}]
댓글 수: 0
답변 (3개)
cr
2022년 12월 1일
readtable(), importdata(), etc.
You may just drag and drop the file into workspace to launch importwizard. Make the appropriate settings and then choose generate code to see the underlying specifics.
Regards.
댓글 수: 4
Star Strider
2022년 12월 1일
C1 = readcell('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1214888/example.txt')
That will at least get it into your workspace.
.
댓글 수: 0
Seth Furman
2022년 12월 7일
fileContents = string(fileread("example.txt"))
jsonStruct = jsondecode(fileContents)
t = struct2table(jsonStruct)
t = convertvars(t,[2 3],"string")
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!