How To Convert data separated by commas into columns.

I have imported a dataset from UCi and it is in .data format. How do i separate these data into separate columns.
Look at an example of two rows below:
{'58, Self-emp-inc, 181974, Doctorate, 16, Never-married, Prof-specialty, Not-in-family, White, Female, 0, 0, 99, ?, <=50K'}
{'50, Private, 485710, Doctorate, 16, Divorced, Prof-specialty, Not-in-family, White, Female, 0, 0, 50, United-States, <=50K'}

Respuestas (1)

Try this
str = fileread('data.txt');
data = strrep(str, '{''', '');
data = strrep(data, '''}', ', ');
data = strrep(data, newline, '');
data = strsplit(data, ', ');
data = reshape(data(1:end-1), 15, []).'
data.txt is attached.

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Nov. de 2020

Respondida:

el 2 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by