opening excel .csv
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone,
I've been working on a project that would allow me to pull data from a .csv file to later plot. The problems I have been running into include not allowing anything to come through: csvread(filename), or even xlsread(filename) just throw errors. I'm under the impression that these two commands should be able to work fine, however, they do not work at all. I don't know if I'm using them incorrectly, or if my 2014a version matlab isn't liking excel 2016? Could it possibly have anything to do with the fact that my file name(20180122Mx00_Go-Stop CE(US)0001.csv) has a space in it?
When using xlsread('myfilename.csv'), I get the following error:
- Error using xlsread (line 128)
- XLSREAD unable to open file '20180122Mx00_Go-Stop CE(US)0001.csv'.
- File 'C:\Users\vc043111\Documents\MATLAB\20180122Mx00_Go-Stop CE(US)0001.csv' not found.
- Error in prac5 (line 5)
- Pattern = xlsread('20180122Mx00_Go-Stop CE(US)0001.csv');
When using csvread('myfilename.csv'), I get this following error:
- Error using csvread (line 34)
- File not found.
- Error in prac5 (line 5)
- Pattern = csvread('20180122Mx00_Go-Stop CE(US)0001.csv');
xlsread('myfilename') will work just fine if I'm using an .xls file, and I understand that changing my spreadsheet file type to that would solve that problem, but I want the user to have the least amount of steps as possible.
1 Commento
Bob Thompson
il 7 Feb 2018
Most likely it simply means that the commands are unable to identify the file properly due to some form of directory error. You could double check the file name, and make sure it is within your matlab path.
To avoid this issue I personally like to use uigetfile() to select the file within the code. This also prevents me from needing to manually change the file name in the script.
[filename, filedir] = uigetfile('*.xlsx','MultiSelect','off');
filepath = fullfile(filedir,filename);
data = xlsread(filepath,'A1:B2');
It works the same way with .csv files, just change the '*.xlsx' to '*.csv' and read command to csvread().
Risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!