LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-11-2009, 10:55 PM   #1
MiniGopal
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Rep: Reputation: 0
reading excel files in c language


hi friends...

i am trying to read excel files through c..
i ve stored the excel file as .csv file. my excel file has the data

data1 data2 data3
data4 data5 data6

i can read all the cell values as

data1,data2,data3,data4,data5,data6

but i want to select each and every cell values separately and to process over it. but i cant able to retrieve all the cell values. i can able to retrieve data1 alone by checking ,.

can anyone help me over tat...

thanks in advance..
 
Old 03-12-2009, 11:21 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
So, show us what you've written so far, and perhaps someone can offer some suggestions to help fix it. For parsing CSV data, you are going to need to make heavy use of string processing functions. strtok() is one that is probably useful, although it can be tripped up by commas embedded in quoted fields. It is almost impossible to suggest a general solution, unless someone knows of a canned library or source package for parsing such files, and it seems likely that such a package exists. I assume that you have a good reason for choosing a C implementation, rather than something like Perl, which makes such tasks almost trivial.
--- rod.
 
Old 03-12-2009, 11:53 PM   #3
MiniGopal
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Original Poster
Rep: Reputation: 0
hi

thanks ya.......

i got it........
 
Old 03-21-2009, 01:50 PM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Here's the real answer to your question:
Quote:
awk 'NR==1{print $3}' csvfile
http://www.linuxquestions.org/questi...0/#post3481680
 
Old 03-24-2009, 03:26 AM   #5
MiniGopal
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Unhappy reading excel files in c

i am really sorry....

i cant able to get tis....

Quote:
awk 'NR==1{print $3}' csvfile

Last edited by MiniGopal; 03-24-2009 at 03:28 AM.
 
Old 03-24-2009, 09:09 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
I don't see how paulsm4's code works for CSV files, either. It would seem to work fine for whitespace separated values. His point that C is the wrong tool for the job should be well taken however. My solution would probably involve something like Perl and the Text::CSV::Simple module. Since you haven't shown any actual data, nor have you given any indication how you wish to process the data, it is impossible to provide anything like a working example.
--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Reading Native Excel Files in Perl LXer Syndicated Linux News 0 09-05-2008 05:40 PM
LXer: Reading Native Excel Files in Perl LXer Syndicated Linux News 0 09-03-2008 01:10 AM
reading integer values from excel using java - interprets it as float kshkid Programming 3 07-28-2008 12:53 AM
perl + excel + reading date values kshkid Programming 6 02-14-2008 01:13 PM
Reading excel files from c language rajesh_b Programming 4 11-25-2004 06:26 AM


All times are GMT -5. The time now is 09:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration