Problems with splitting with readtable

조회 수: 13 (최근 30일)
Eleen
Eleen 2023년 12월 11일
이동: Cris LaPierre 2023년 12월 11일
Hi all,
I have a question regarding the readtable-function. I want to use this function to import a .csv-file into a table, but I'm having some problems with correclty splitting the data from this file. I added an example file of the file I want to import. The variable names of the table that I want to create, are in row 3 and the data are in row 4-6. By using the readtable function and specifying 'NumHeaderLines', I can correclty split the variable names. However, it does not correctly split the data, even when I'm using the 'Delimiter' option. All the data always ends up in the first column, but that is not how I want it. In the first data row ,the data from the variable 'Apparaat' should ABC DEF, from 'Serienummer' ABC123-ABC123-ABC123-ABC123-ABC123, from 'Tijdstempel apparaat' 24-07-2022 02:18, from 'Gegevenstype' 0, from 'Historische glucose mmol/l "6.0" and all the others columns should be empty. It does not matter that much what kind of datatypes are in the table, I can change them afterwards.
Does anyone know or has any tips how I can correctly split the data?
Thanks a lot!
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2023년 12월 11일
seems the old csvimport is better handling your csv file
out = csvimport('Examplefile.csv');
out = 6×5 cell array
{'Patiëntrapport'} {'Gegenereerd op' } {'07-12-2023 13:29…'} {'Gegenereerd door'} {'Eleen Schupp' }
{'Examplefile' } {0×0 char } {0×0 char } {0×0 char } {0×0 char }
{'Apparaat' } {'Serienummer' } {'Tijdstempel appa…'} {'Gegevenstype' } {'Historische gluc…'}
{'"ABC DEF' } {'ABC123-ABC123-AB…'} {'24-07-2022 02:18' } {'0' } {'""6' }
{'"DEF GHI' } {'ABC123-ABC123-AB…'} {'24-07-2022 02:33' } {'0' } {'""7' }
{'"GHI ' } {'ABC123-ABC123-AB…'} {'24-07-2022 02:48' } {'0' } {'""8' }

댓글을 달려면 로그인하십시오.

답변 (1개)

Eleen
Eleen 2023년 12월 11일
이동: Cris LaPierre 2023년 12월 11일

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by