没有合适的资源?快使用搜索试试~ 我知道了~
读写CSV文件函数(代码)
4星 · 超过85%的资源 需积分: 10 12 下载量 146 浏览量
2009-09-24
15:39:34
上传
评论 1
收藏 7KB TXT 举报
温馨提示
试读
10页
实现读写CSV文件的两个函数,可直接调用,不过保存的是某种固定的格式
资源推荐
资源详情
资源评论
void CSIMApp::GetCSV(CString strFileName)
{
CString strT;
CString strT0;
CString strDevID;
CString strRetryNum;
CFileException e;
int pos1=0;
int pos2=0;
int pos=0;
int nStrNum=0;
int nStrLen;
channel *pChan=NULL;
dev *pDev=NULL;
tag *pTag=NULL;
CString strChanName,strDevName;
CStdioFile stdFile;
if(stdFile.Open(strFileName,CFile::modeRead|CFile::shareDenyNone,&e)) //打开CSV文件
{
for(int i=0;i<2;i++)
stdFile.ReadString(strT);
/*读取通道信息*/
if(strT.GetAt(0)=='!')
{
stdFile.ReadString(strT);
nStrLen=strT.GetLength();
while(strT.GetLength()>0)
{
CString strT;
CString strT0;
CString strDevID;
CString strRetryNum;
CFileException e;
int pos1=0;
int pos2=0;
int pos=0;
int nStrNum=0;
int nStrLen;
channel *pChan=NULL;
dev *pDev=NULL;
tag *pTag=NULL;
CString strChanName,strDevName;
CStdioFile stdFile;
if(stdFile.Open(strFileName,CFile::modeRead|CFile::shareDenyNone,&e)) //打开CSV文件
{
for(int i=0;i<2;i++)
stdFile.ReadString(strT);
/*读取通道信息*/
if(strT.GetAt(0)=='!')
{
stdFile.ReadString(strT);
nStrLen=strT.GetLength();
while(strT.GetLength()>0)
{
pos1=0;
pos2=0;
pos=0;
nStrNum=0;
pChan=new channel;
while((pos2=strT.Find(',',pos2+1))>0) //寻找地址中的分号位置
{
if(pos1==0)
{
strT0=strT.Mid(0,pos2);
}
else
{
if(pos2>(pos1+1))
strT0=strT.Mid(pos1+1,pos2-pos1-1);
else
strT0="";
}
switch(nStrNum)
{
case 0:
pChan->chanName=strT0;
break;
case 1:
pChan->chanDescription=strT0;
break;
case 2:
pChan->chanIPAddr=strT0;
pos1=0;
pos2=0;
pos=0;
nStrNum=0;
pChan=new channel;
while((pos2=strT.Find(',',pos2+1))>0) //寻找地址中的分号位置
{
if(pos1==0)
{
strT0=strT.Mid(0,pos2);
}
else
{
if(pos2>(pos1+1))
strT0=strT.Mid(pos1+1,pos2-pos1-1);
else
strT0="";
}
switch(nStrNum)
{
case 0:
pChan->chanName=strT0;
break;
case 1:
pChan->chanDescription=strT0;
break;
case 2:
pChan->chanIPAddr=strT0;
剩余9页未读,继续阅读
资源评论
- zrjing2013-11-05有点用,有个破解版的国外的libxl.dll更好用
- hello_journey2014-07-23可以直接使用
lixiang_njut
- 粉丝: 11
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功