当前位置:网站首页>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中
边栏推荐
猜你喜欢
随机推荐
(三)文件操作之一——文件IO
ssm整合
DOM —— 事件绑定与解绑
网络运维系列:GoDaddy Shell DDNS配置
Scala的基础语法(小试牛刀)
详解C语言中的位操作运算符可以怎么用?
WebRTC 中有关 Media Stream & Track & Channel 之间的关系
网络运维系列:二级域名启用与配置
Feign Client 超时时间配置不生效
怎么使用 smart_rtmpd 的纯 webrtc 功能?
【IP基本原理-ARP原理】
Vmware workstation16 安装 ESXi 6.7 详细步骤
基于Visual Studio 2015的CUDA编程(一):基本配置
CDN的加速原理是什么?
【软件测试】项目中关于测试人员的简单介绍
小知识系列:Fork之后如何与原仓库分支同步
How to tick the word box?
【数据读写】csv文件与xls/xlsx文件
网络请求——跨域 的概念
一分钟之内搭建自己的直播服务器?