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

Thread: CSV file read

  1. #1
    Join Date
    Dec 2012
    Posts
    3

    CSV file read

    Hello,

    i have problem reading CSV file, i found many solutions but i still got one problem.
    I need to read CSV file and then these values show in List Control and here i have problem. Idk how to display it in List, any help?

    Thanks!

  2. #2
    Join Date
    Dec 2012
    Posts
    3

    Re: CSV file read

    I forgot to mention that i'm programing in MFC.

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,127

    Re: CSV file read

    Your question is way too vague to get any meaningful help. What have you done and where are you stuck? If it's just the list control, use InsertItem.

  4. #4
    Join Date
    Dec 2012
    Posts
    3

    Re: CSV file read

    I have a classic menu and Open button on it, and i have a cList in which i need to show values from csv file when open button is clicked...

    Got this so far...but i think it's not ok.

    void CAboutDlg::OnFileOpen()
    {
    CString strRead;
    CStdioFile file;
    // TODO: Add your command handler code here
    TCHAR filters[] = _T("files (*.csv)|*.csv||");
    CString path;

    CFileDialog dlg(TRUE, _T("csv"), _T("*.csv"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, filters);
    dlg.m_ofn.lpstrTitle = _T("Open...");


    if(dlg.DoModal() == IDOK)
    {
    path = dlg.GetPathName();

    //
    // Open file
    if(!file.Open(path,CFile::modeRead|CFile::typeText)) return;
    //

    while(file.GetPosition() != file.GetLength())
    {
    // Save the line to string
    file.ReadString(strRead);
    }
    file.Close();

    }

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,127

    Re: CSV file read

    Typically you'd just check the return value of ReadString to test of end of file. I've never seen it done the way you're doing it.

    I guess next you need to learn how to parse your CString. Honestly though, perhaps you need to work through a tutorial book. The forum's not going to be the best way to learn the basics and there's a LOT to learn.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center