C语言进行csv文件数据的读取:
#include
#include
#include
#include
#include
int main(){
FILE *fp = NULL;
char *line,*record;
char buffer[];//20450这个数组大小也要根据自己文件的列数进行相应修改。
if((fp = fopen("All-w.csv", "r")) != NULL)
{
fseek(fp, 16415L, SEEK_SET); //定位到第二行,每个英文字符大小为1,16425L这个参数根据自己文件的列数进行相应修改。
while ((line = fgets(buffer, sizeof(buffer), fp))!=NULL)//当没有读取到文件末尾时循环继续
{
record = strtok(line, ",");
while (record != NULL)//读取每一行的数据
{
printf("%s ", record);//将读取到的每一个数据打印出来
record = strtok(NULL, ",");
}
}
fclose(fp);
fp = NULL;
}
}
CSV文件数据如何读取、导入、导出到新的CSV文件中以及CSV文件的创建
CSV文件数据如何读取.导入.导出到新的CSV文件中以及CSV文件的创建