Importing csv files properly
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to import a csv file which contains 'comma'(,) inside 'quotation' marks(" ") in some cells. Here is one example.
RAB13,"RAB13, member RAS oncogene family",3.042175424,0.009699723
How can I NOT split the data at ',' if they are inside quotation? The csv is attached. Any help is appreciated!
0 comentarios
Respuestas (2)
Simon Chan
el 18 de Jul. de 2021
You may use readcell and the output is a cell array.
The first row shows the header and the rest of the rows contains the requried data:
rawdata = readcell('test1.csv');
header = rawdata(1,:); % Extract the header
data = rawdata(2:end,:);
0 comentarios
Star Strider
el 18 de Jul. de 2021
2 comentarios
Peter Perkins
el 27 de Jul. de 2021
Add "TextType","string" to that readtable call and you have a winner!
Star Strider
el 27 de Jul. de 2021
Following up on that ...
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/687498/test1.csv', 'VariableNamingRule','preserve', 'TextType','string')
.
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!