-
December 26th, 2012, 04:33 PM
#1
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!
-
December 26th, 2012, 04:36 PM
#2
Re: CSV file read
I forgot to mention that i'm programing in MFC.
-
December 26th, 2012, 04:54 PM
#3
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.
-
December 26th, 2012, 05:56 PM
#4
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();
}
-
December 26th, 2012, 06:41 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|