User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 425,928 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,655 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1785 | Replies: 3
Reply
Join Date: Nov 2006
Posts: 10
Reputation: Harshita_garg is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Harshita_garg Harshita_garg is offline Offline
Newbie Poster

Help problem opening CSV file

  #1  
Feb 5th, 2007
Hi All!!

I am relatively new to C++ programming so please forgive me if my question is very basic or silly. I am trying to read files in C++. It opens text based files properly but doesnt open csv files , though I am saving them in the same directory. It doesnt open the file even if we save the csv file as txt file. Also my program is opening the files that are being saved in the current directory only. If we save the same file in other directory & specify the whole path in program then also it fails to open that file. I dont know wht the problem is. Could you people please help me with this.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,481
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Rep Power: 8
Solved Threads: 102
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: problem opening CSV file

  #2  
Feb 5th, 2007
It is a bit strange that you can open text files but not csv files. They are essentially both text files, and only the file extensions are different. So give us the code that you are using to open the files. Maybe we can find something more by looking at the code. If you are using file paths, you should use double backslashes like "C:\\temp\\temp.txt".
バルサミコ酢やっぱいらへんで
Reply With Quote  
Join Date: Nov 2006
Posts: 10
Reputation: Harshita_garg is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Harshita_garg Harshita_garg is offline Offline
Newbie Poster

Re: problem opening CSV file

  #3  
Feb 5th, 2007
Hi!! heres the code I am using:-

const int MAX=100;
char str[MAX];
ifstream infile;
infile.open("abc.csv");
// I have also tried giving the full path here
if(!infile)
   cout<<"unable to open file";

{
   infile.getline(str,MAX);
   cout<<endl<<str;
} 

When compiled & run, this program opens txt file but is unable to open a csv file.

Please help.
Last edited by WaltP : Feb 5th, 2007 at 3:07 pm. Reason: Corrected CODE tags -- use the Preview button
Reply With Quote  
Join Date: Nov 2006
Posts: 10
Reputation: Harshita_garg is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Harshita_garg Harshita_garg is offline Offline
Newbie Poster

Re: problem opening CSV file

  #4  
Feb 5th, 2007
Hey!!!

My program worked. I have been doing a silly mistake. I was saving the excel file with csv extension but not as a text file. Thanks wolfpack! your advice of using double backslash worked & it solved my 2nd problem.

Thankyou guys!!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 9:06 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC