How to separate a column which has a comma separated values, into 2 different values?

조회 수: 8 (최근 30일)
Hello, Who knows how to separate this column into the name of the city and state (comma-separated value)? and then I need to add this new column to my current table, so I would love to know, thanks in advance!

답변 (1개)

Voss
Voss 2023년 2월 2일
city = ["Abilene, TX"; "Waco, TX"; "Arcata/Eureka, CA"];
t = table(city)
t = 3×1 table
city ___________________ "Abilene, TX" "Waco, TX" "Arcata/Eureka, CA"
city_state = split(t.city,", ");
t.city = city_state(:,1);
t.state = city_state(:,2);
t
t = 3×2 table
city state _______________ _____ "Abilene" "TX" "Waco" "TX" "Arcata/Eureka" "CA"

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by