필터 지우기
필터 지우기

readtable csv with one column containing a field with commas

조회 수: 20 (최근 30일)
Derek
Derek 2024년 6월 25일 19:20
댓글: Derek 2024년 6월 25일 20:14
I'm reading a CSV file with the command:
readtable(Logic_file, 'ReadVariableNames', true, 'Format', '%d%d%f%s%s%d%s','EmptyValue',0);
My problem is that the supplier of input file has change the last column from a string to something like this:
{'string1', 'string2'}
readtable() is seeing the commas in this {} field and trying to make more columns. I want readtable to treat whatever is in the {...} as a single field not to be broken up. Any ideas would be welcome

채택된 답변

Walter Roberson
Walter Roberson 2024년 6월 25일 19:46
readtable(Logic_file, 'ReadVariableNames', true, 'Format', '%d%d%f%s%s%d%[^\n]','EmptyValue',0);
This will handle columns with and without {}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by