读取CSV文件
CStdioFile file;
file.Open(strFilepath,CFile::modeRead);
CString str;
while(file.ReadString(str))
{
str = str.Trim(_T(" "));
//去掉字符串中的单引号
if(str.GetLength()>=2)
{
str.Replace(_T("\""),_T(" "));//\"代表单引号
}
CString substr[6];
int count=0;
int index = str.Find(_T(","));
while (index != -1 && count<5)
{
substr[count++] = str.Left(index);
str=str.Right(str.GetLength()-index-1);
index = str.Find(_T(","));
}
substr[count++]=str;
CString stmp;
stmp.Format(_T("%s %s %s %s %s %s %s %s %s %s"),substr[0],substr[1],substr[2],substr[3],substr[4],substr[5]);
MessageBox(stmp);
}
file.Close();