CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: csv

  1. #1
    Join Date
    Apr 1999
    Posts
    2

    csv

    Hi

    What do i need to read a .csv file eg. produced by MS Exel ?

    Thanks in advance.
    Steen


  2. #2
    Join Date
    Apr 1999
    Location
    Germany
    Posts
    53

    Re: csv

    This is very simple, a CSV File produced by Excel has columns which are seperated by ;
    So just open that file like:

    FILE *stream;
    char Data[1024];
    CString temp;
    if( ( stream = fopen( "file.csv", "rt" ) )
    {
    for( ;; )
    {
    memset( data, 0, 1024 );
    fgets( data, 1024, stream );
    if( feof( stream ) ) break;
    // if you are here, one line of text is in data
    // now produce some code which reads each column of that stream, e.g.: getColumn( ";", data, n, &temp );
    }
    fclose( stream );
    }


    good luck !


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured