Reading a complex CSV file and converting to MAT

6 ビュー (過去 30 日間)
James
James 2017 年 11 月 13 日
コメント済み: James 2018 年 1 月 10 日
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 件のコメント
per isakson
per isakson 2017 年 11 月 13 日
編集済み: per isakson 2017 年 11 月 13 日
"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 2017 年 11 月 20 日
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!

サインインしてコメントする。

回答 (1 件)

Jule
Jule 2018 年 1 月 10 日
編集済み: Jule 2018 年 1 月 10 日
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 件のコメント
Jule
Jule 2018 年 1 月 10 日
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 2018 年 1 月 10 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by