필터 지우기
필터 지우기

Reading data from csv with non uniform formatting

조회 수: 6 (최근 30일)
AG15
AG15 2023년 4월 24일
댓글: Cris LaPierre 2023년 4월 24일
Hi,
I am trying to read data from a cvs file (sample attached) with uneven formatting where there are a few sentences and lines with missing data points. I have been reading the file and then getting the row number for each time the column with is different to extract the data. I am trying to read ( and remove) the sentences and also remove the partially complete rows and creating one array from the remaining data. Is there any better way of doing this withouth having to check which row is incomplete? Any suggestions would be very helpful.
Thank you
  댓글 수: 5
AG15
AG15 2023년 4월 24일
Thank you
Cris LaPierre
Cris LaPierre 2023년 4월 24일
Yes. If you are new to tables, see this page on how to access data in tables.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 4월 24일
I would use readtable with the settings to 'omitrow' when data is missing.
T = readtable('sample.csv','MissingRule','omitrow')
T = 11×5 table
Var1 Var2 Var3 Var4 Var5 _____ ____ ____ ____ ____ {'A'} 1 2 3 4 {'B'} 1 2 3 4 {'C'} 1 2 3 4 {'D'} 1 2 3 4 {'A'} 1 2 3 4 {'B'} 1 2 3 4 {'C'} 1 2 3 4 {'A'} 1 2 3 4 {'D'} 1 2 3 4 {'C'} 1 2 3 4 {'E'} 1 2 3 4

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by