当前位置:网站首页>CSV file with the data read and write 】 【 XLS/XLSX file
CSV file with the data read and write 】 【 XLS/XLSX file
2022-08-02 16:32:00 【Zhi Zhao】
目录
一、csv格式与xls/xlsx格式的区别
csv格式与xls/xlsxFormat of the file on the style looks like,且都可以用EXCEL打开,其中xls是Office2003版本的EXCEL表格,xlsx是2007版本及以上的EXCEL表格,这两种EXCELTables can be usedxlsread函数、xlswrite函数来读写文件.但csvFormat of the file with thexls/xlsxFormat of the file with different nature.
1)csv是文本文件,可以用记事本打开;xls/xlsx是二进制文件,只有用EXCEL才能打开.
2)csvFile can only save activity work cell in the table shown in the text and numeric,Data in each column to a comma,End of each line to enter a newline.If the cell contains a comma in the,It is the contents of the cell in double quotation marks.xls/xlsxFile between each cell separator forTab.
3)csv文件可以用记事本打开,进而转为txt格式的文件;xls/xlsx不能直接转为txt格式.If you want to convert,You need to save ascsv格式,然后再将csv以txt方式打开,点击另存为txt文件.
二、Two kinds of file formats to read and write operations
1.csv文件的读/写函数
csvread
语法:
data = csvread(filename);
filenameFor the specified directory file,例如 filename = ‘E:\MATLAB_Study\数据.csv’.
data = csvread(filename, r, c);
r、cRepresent the line and column number of the specified file,r和c为0时,Representatives from the first row and first column in the file to read data.
data = csvread(filename, r, c, rng);
rngSaid in the designated line and column number range between reading data,例如 rng = [R1 C1 R2 C2],R1和R2代表行号,C1和C2代表列号.
csvwrite
data = rand(5,6); % 产生随机数
filename = '数据.csv'; % 文件名
csvwrite(filename,data); % 写数据
2.xls/xlsx文件的读/写函数
xlsread
语法:
filename = '数据.xlsx'; % 文件名
sheet = 'sheet1'; % 工作表
range = 'A2:C3'; % 读取范围
[data2, text, rawData] = xlsread(filename,sheet,range);
sheet:指定读取的工作表;
range:The scope of work table;
data:数值数据;
text:文本数据;
rawData:原始数据,The value in the include file and text data.
xlswrite
filename = '写数据.xlsx'; % 文件名
data = rand(5,6); % 产生随机数
sheet = 'sheet2'; % 工作表
xlswrite(filename,data,sheet);
三、应用案例
1.实例1
参考资料
[1] csv和xlsx区别
[2] matlab将多个excelRead both to aexcel的不同sheet中
边栏推荐
猜你喜欢
随机推荐
【SVM回归预测】基于LibSVM实现多特征数据的预测
对象头和synchronized的升级
自动化之参数化
关于机组的部分知识点随笔
OpenPose command line
Mysql索引底层数据结构
DOM —— 元素盒子模型
【软件测试】进阶篇
Golang学习(三十五) go 连接redis
Three-way joint interface data security issues
Dcoker的安装及使用命令
smart_rtmpd 轻松突破 C100K 测试
VLAN原理
转行软件测试,从零收入到月薪过万,人生迎来新转折
test3
【软件测试】项目中关于测试人员的简单介绍
这几年让你大呼惊人的AI应用,都离不开这项技术
DOM —— 事件代理
makefile——杂项
解决跨域问题的方法 --- CORS