how to create csv file

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2008
Posts: 3
Reputation: morrison is an unknown quantity at this point 
Solved Threads: 0
morrison morrison is offline Offline
Newbie Poster

Re: output/write to a xls file

 
0
  #1
Jan 2nd, 2008
Originally Posted by Ancient Dragon View Post
You cannot write directly to an *.xls file and expect Excel to read it because *.xls files are not plain text files -- they contain a lot of formatting information that is readable only by Excel program.

The easiest way to do it is to creates *.csv files which Excel can import. Fieids (cells) are commma or sometimes tab separated, with CR/LF between each row. Using your example you might write it like this: Text should be surrounded with quotes (see first example below)
  1. myfile << "\"Hello World\"," << nums[1] << "," << nums[2] << "," nums[3] << "\n";
  2.  
  3. or
  4. myfile << nums[1] << "\t" << nums[2] << "\t" nums[3] << "\n";
Above thing is correct to write in csv but I am facing one problem to write it in csv as html editor code cannot be write as csv as it generates error on csv file writing.Due to this the only way is to write an excel file as data in html format can also be write.

Here in writing excel file I have an script which I used in writing it but while reading it using another script for excel it generates an error as mentioned below:-

"The filename shipaccountactivity1.xls is not readable"

Can u plz help me in above case as how can I write it so that it can easily be readable.......

Thanks in advance.....
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,672
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1502
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: output/write to a xls file

 
0
  #2
Jan 2nd, 2008
Do you mean you are using an html editor to write the csv file? Then why is this question in the C board?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3
Reputation: morrison is an unknown quantity at this point 
Solved Threads: 0
morrison morrison is offline Offline
Newbie Poster

Re: output/write to a xls file

 
0
  #3
Jan 2nd, 2008
No sir,I m using php script but I m writing excel with html content as I have one field with product description.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3
Reputation: morrison is an unknown quantity at this point 
Solved Threads: 0
morrison morrison is offline Offline
Newbie Poster

Re: output/write to a xls file

 
0
  #4
Jan 2nd, 2008
Originally Posted by Ancient Dragon View Post
Do you mean you are using an html editor to write the csv file? Then why is this question in the C board?
It doesn't matter whether it is php or c post.Thing is that html code cannot be write on an csv and that's y only excel file will be written in such case and I have done it very neately.I am just going through concept and not on language........

So much thanx........
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,297
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 178
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Re: how to create csv file

 
0
  #5
Jan 2nd, 2008
Python has a csv module, but why has this thread been bumped into the Python forum?
No one died when Clinton lied.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4246 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC