Header Ads

Hii,I am Anand Nayak.This blogger is make for specially basic programs of some language.

Csv File

What are CSV files?


CSV files are text files with information separated by commas, saved with the extension .csv. They allow large amounts of detailed data to be transferred ‘machine-to-machine’, with little or no reformatting by the user.
You can open a CSV file with any spreadsheet, statistics, or analysis program, such as Microsoft Excel, the R statistical environment, or Python. 
CSV files may open in Excel by default, but they are not designed as Excel files. If CSV files are opened in Excel, certain information (eg codes with leading zeros) could be missing. Ideally, they should be imported into a database designed to preserve the CSV format.

Lets's See With Example How to Read & Write Value in File Handling....

#include<stdio.h>
#include<conio.h>
#include<process.h>
    void main()
     {
          int i,age,cols,id;
          char name[20],address[100];
          FILE *fp;
          clrscr();
              fp=fopen("Aadhar card Details.csv","w");
                 if(fp==NULL)
                   {
             printf("file cannot open");
              exit(0);
                      }
     printf("enter your name");
    gets(name);
    printf("enter your age");
    scanf("%d",age);
    printf("Enter your address");
    scanf("%s",address);
      fprintf(fp,"ID,");
      fprintf(fp,"Name,");
     fprintf(fp,"Age,");
     fprintf(fp,"Address,\n");
       for(i=0;i<10;i++)
        {
          fprintf(fp,"%d,",i);
         fprintf(fp,"%s%d,",name,i);
         fprintf(fp,"%d%d,",age,i);
         fprintf(fp,"%s%d,\n",address,i);
       }
   fclose(fp);
   getch();
  }

No comments