readtable() custom variable names
조회 수: 360 (최근 30일)
이전 댓글 표시
I am using the below command to read a csv file into a table called T.
T = readtable("library.csv")
Now, the first row of the csv inludes the column headers, or variable names you can say. However, I want to change those variable names as I want. I have inspected readtable() documentation, but could not find the solution.
How can I do this?
Thanks.
댓글 수: 0
채택된 답변
Ameer Hamza
2020년 4월 4일
편집: Ameer Hamza
2020년 4월 4일
One way is to change the variable names after reading the file like this.
t = readtable("library.csv");
t.Properties.VariableNames = {'name1', 'name2'}; % names of columns
댓글 수: 6
Walter Roberson
2022년 5월 18일
table() objects must have unique names for each variable. It is not possible to create a table() object which does not have variable names.
You can readtable() and pass VariableNames at the time of reading, thereby giving some name of your choice.
You can skip a header by using HeaderLines, 1 and ReadVariableNames, false
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!