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

11 ビュー (過去 30 日間)
Aron Alexander
Aron Alexander 2023 年 2 月 2 日
回答済み: Voss 2023 年 2 月 2 日
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 Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by