How to separate a column which has a comma separated values, into 2 different values?
3 views (last 30 days)
Show older comments
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!

0 Comments
Answers (1)
Voss
on 2 Feb 2023
city = ["Abilene, TX"; "Waco, TX"; "Arcata/Eureka, CA"];
t = table(city)
city_state = split(t.city,", ");
t.city = city_state(:,1);
t.state = city_state(:,2);
t
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!