First variable of table formatted differently for similar CSV inputs
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have two CSV files, both produced by the same software, according to the same template. Both files look the same when opened in Excel, and cells are all of the content type "General". The only difference is the last few rows, which in one case have been deleted.
However, when reading the CSVs into Matlab with readtable, the first column/variable is formatted differently, in one case as cell ('1') and in the other case as double (1), as can be seen below. All other variables are formatted identically, which makes this so strange.
>> T = readtable('02.csv', 'readvariablenames', true)
T =
rep file condition corrAns n notes_started_mean notes_started_raw notes_started_std notes_stopped_mean notes_stopped_raw notes_stopped_std phrase_started_mean phrase_started_raw phrase_started_std phrase_stopped_raw rating_response_mean rating_response_raw rating_response_std rating_rt_mean rating_rt_raw rating_rt_std rating_started_mean rating_started_raw rating_started_std rating_stopped_raw rating_text_started_mean rating_text_started_raw rating_text_started_std rating_text_stopped_raw takeBreak_started_raw takeBreak_stopped_raw order
_________________ __________________ _________ _______ ___ __________________ _________________ _________________ __________________ _________________ _________________ ___________________ __________________ __________________ __________________ ____________________ ___________________ ___________________ ______________ _____________ _____________ ___________________ __________________ __________________ __________________ ________________________ _______________________ _______________________ _______________________ _____________________ _____________________ _____
'1' 'stimuli/09C4.wav' 'C4' 1 1 135.42 135.42 0 144.58 144.58 0 135.4 135.4 0 NaN 2 2 0 1.676 1.676 0 9.2157 9.2157 0 NaN 144.58 144.58 0 NaN NaN NaN 0
and
>> T = readtable('03.csv', 'readvariablenames', true)
T =
rep file condition corrAns n notes_started_mean notes_started_raw notes_started_std notes_stopped_mean notes_stopped_raw notes_stopped_std phrase_started_mean phrase_started_raw phrase_started_std phrase_stopped_raw rating_response_mean rating_response_raw rating_response_std rating_rt_mean rating_rt_raw rating_rt_std rating_started_mean rating_started_raw rating_started_std rating_stopped_raw rating_text_started_mean rating_text_started_raw rating_text_started_std rating_text_stopped_raw takeBreak_started_raw takeBreak_stopped_raw order
___ __________________ _________ _______ _ __________________ _________________ _________________ __________________ _________________ _________________ ___________________ __________________ __________________ __________________ ____________________ ___________________ ___________________ ______________ _____________ _____________ ___________________ __________________ __________________ __________________ ________________________ _______________________ _______________________ _______________________ _____________________ _____________________ _____
1 'stimuli/14C1.wav' 'C1' 2 1 171.52 171.52 0 178.34 178.34 0 171.51 171.51 0 NaN 2 2 0 1.021 1.021 0 6.8371 6.8371 0 NaN 178.34 178.34 0 NaN NaN NaN 0
0 comentarios
Respuesta aceptada
Jan
el 15 de Mayo de 2019
Look in line 70 to 77 of 02.csv:
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
extraInfo,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
session,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
participant,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
date,2019_May_14_1543,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
expName,hSs_syntactic,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
psychopyVersion,3.1.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
frameRate,59.97727707,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
In 03.csv all values of the first column are scalar numbers, but in 02.csv the elemen in line 70 is empty, and in 71 to 78 there are strings. Of course Matlab cannot know how to handle than an imports them as strings.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!