How do you allow a user to input a .csv file?

What command is used to allow a user to input a .csv file, also how is the command formatted? Many thanks!

댓글 수: 2

KL
KL 2017년 10월 15일
what do you mean by "allow a user"? do you want to have a gui dialog box?
Rochollywood
Rochollywood 2017년 10월 15일
not necessarily, I believe it needs to be input through the command window

댓글을 달려면 로그인하십시오.

답변 (1개)

KL
KL 2017년 10월 15일
편집: KL 2017년 10월 16일

0 개 추천

If you want to import data from this file,
data = csvread('yourfilename.csv')
if you want user to pick the file using a dialog box, then
[fileName, pathName] = uigetfile('*.csv');
data = csvread(fullfile(pathName,fileName)) ;

댓글 수: 4

Rochollywood
Rochollywood 2017년 10월 15일
That is closer, but what if I don't know the path, or the file name the user wants to input?
KL
KL 2017년 10월 16일
That's exactly what the second suggestion does. It lets the user browse through his folders to select a csv file.
Note that we recommend against using a variable named "path", as "path" is the name that MATLAB uses to manage how to find files.
KL
KL 2017년 10월 16일
Thanks for pointing it out Walter, I edited the answer.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

질문:

2017년 10월 15일

댓글:

KL
2017년 10월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by