当前位置:网站首页>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中
边栏推荐
猜你喜欢
随机推荐
MYSQL5.7详细安装步骤
解决跨域问题的方法 --- CORS
【网络设备远程登陆配置SSH/Telnet 】
LAMP 环境搭建 yum源安装方式 (Apache 2.4.6 +mysql 8.0.28+php 8.1.3)
Oauth2.0 Supplement
Linux下mysql的彻底卸载
[Inter-process communication]: pipe communication/named/unnamed
Feign Client 超时时间配置不生效
Golang基础教程
小知识点系列:StringUtil.isEmpty()与StringUtil.isBlank()的区别
排列熵、模糊熵、近似熵、样本熵的原理及MATLAB实现之近似熵
抽象队列同步器AQS应用Lock详解
个人成长系列:业务、技术学习书单
JMM&synchronized&volatile详解
mongodb连接本地服务失败的问题
静态方法的缺失
Dcoker的安装及使用命令
abstract和接口的基础知识
grub 命令使用
Object.defineProperty方法(详解)