Reading a complex CSV file and converting to MAT

6 Ansichten (letzte 30 Tage)
James
James am 13 Nov. 2017
Kommentiert: James am 10 Jan. 2018
Hi all,
I'm trying to read in a large CSV file that has been exported from Vicon Nexus -- with 3D motion capture data -- with as minimal modification to the original exported file as possible (TestData.CSV accessed here -- attache) .
From what I've read, .MAT file would be the best file to convert to but because of the header info and the 2 separated sets of data in the same file -- "TRAJECTORIES" and "FORCE PLATES" -- I believe the only option I have is to use textscan. I need to use both sets of data and index an unknown number -- experimenting -- of columns & row.
Eventually I only want to read in the variables that are needed, which are located in different columns and in both of the two different data sets. The two different data sets are best exported into the 1 CSV file to contain all the variables needed for further analysis down the line. Is it possible to use textscan in this case? Any help would be much appreciated. Cheers.
  6 Kommentare
per isakson
per isakson am 13 Nov. 2017
Bearbeitet: per isakson am 13 Nov. 2017
"Nexus has an Offline Data SDK specifically designed to allow users to push and pull specific items of data into MATLAB" Whatever that is?
James
James am 20 Nov. 2017
Thanks a whole lot! readtable seemed to do the trick! Because of admin issues with running Nexus 1.x.x on Windows 10, I couldn't attempt to use the Matlab integration into Nexus. Cheers again!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jule
Jule am 10 Jan. 2018
Bearbeitet: Jule am 10 Jan. 2018
Hi James!
I am dealing with the same kind of csv-files and was wondering if you could help me out here. I managed to import the file using readtable. However, now I can't find a possibility to detect where the needed variables are in this table.
find(T=={'FORCE PLATES'})
gave the error 'Undefined operator '==' for input arguments of type 'table'.' Hope you or someone else here can help me out.
Thanks!
  5 Kommentare
Jule
Jule am 10 Jan. 2018
Re Error: Since I only have real patient data, I'm not allowed to upload it here. But my csv is very similar to yours. I have the sections ANALYSIS, EVENTS, ANALOG and FORCE PLATE. With every file, the error occurs at the line under 'ANALOG'. Matlab is right saying that there is only one comma ('800.000000,Hz'), however the same appears in the line under 'TRAJECTORIES' (l. 18 in your example file) without producing an error there. Interestingly, if I delete the problematic line, readtable works but deletes everything above said line. Matlab seems to think everything above this is header. That does not happen with the xlsx files.
James
James am 10 Jan. 2018
Firstly, you could try and edit the CSV files to remove the unwanted comma/s and then try readtable again.
Secondly, as long as you can get the data into a cell array then you can index that, so if you can already do that then it may pay to carry on.
Hope that helps.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by