How to import Table and column header from two diffrent files?

5 次查看(过去 30 天)
hey guys i have a problem importing data from my .csv file and my headers from my .txt file
when i open my data.csv in excel i get them in a single column with a '','' delimiter between them.
my txt file contains my headers for data columns they are seprated with a ''|'' delimiter .
how can i import these into a single table which i can work with ?
i tried readtable or importdata but couldnt find the correct options
btw im using matlab online r2020b and im trying to do everything with program code to use as in my internship report

采纳的回答

dpb
dpb 2020-11-21
W/o an example to confirm but from the description alone something like:
tData=readtable('thedatafile.csv');
hdrs=readcell('thehdeadersfile.txt');
tData.Properties.VariableNames=hdrs;
Which begs the question of why not create a single file containing column headings and data together to begin with?
  2 个评论
ali koulani
ali koulani 2020-11-21
编辑:ali koulani 2020-11-26
thanks i think this is the correct answer, i will try it tommorow aand post an update
edit:
data=readtable('DFL_stat_20_09_23.csv');
hdrs=["UEin","std_UEin","Un","std_Un","Us","std_Us","Ur","std_Ur"];%vektor of my headlines
data.Properties.VariableNames=hdrs;
i still dont know why the readcell funktion didnt work to read the headlines from the text file
this is the text file
UEin | std_UEIN | Un | std_Un | Us | std_Us |Ur | std_Ur
dpb
dpb 2020-11-26
Would have to see the code and the actual file to know...although the code and error in context might point to the cause. In general, we can't diagnose what we can't see.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R12.1

Community Treasure Hunt

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

Start Hunting!

Translated by