LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-19-2009, 05:26 AM   #1
MiniGopal
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Rep: Reputation: 0
problem in accessing excel files


hi friends...

i am retrieving the excel file contents using c program and using strtok() function...

but if my excel file contains data such as

data1 data2 data3
data4 data5 data6

then my program is resulting as

data1
data2
data3
data4
data5
data6

but i cant able to retrieve a single cell data alone.. tat is if i want to access data3 i cant able to retrieve....

can anyone help me.....

thanks....
 
Old 03-19-2009, 07:55 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by MiniGopal View Post
can anyone help me.....
Only if you show the code...
(don't forget, in [CODE] tags, please).
--- rod.
 
Old 03-19-2009, 09:35 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
theNbomr -
Quote:
Quote:
Originally Posted by MiniGopal
can anyone help me.....
Only if you show the code...
(don't forget, in [code] tags, please).
<= Well said!
MiniGopal -

Like theNbomr suggested - it might be nice if you gave some clues as to how you were trying to solve the problem - so we could intelligently suggest what might be going wrong.

Additionally, I'm curious: how the heck are you trying to parse "an Excel file" (which, I presume, is a binary .xls or .xlsx file) ... with "C" and "strtok()"???

Thanx in advance .. PSM
 
Old 03-20-2009, 01:36 AM   #4
MiniGopal
LQ Newbie
 
Registered: Feb 2009
Posts: 6

Original Poster
Rep: Reputation: 0
accessing excel files in c

hi..

my coding is
[void main()
{
FILE *fptr;
char *res;
char name,data[175],val[20][20],data1,*dat[20];
int i=0,count=0,length;
int x=0;
clrscr();
fptr=fopen("data.csv","r");
while(name!=EOF)
{
name=getc(fptr);
if(name!=' ')
data[count]=name;
count++;
}

i=0;

res=strtok(data,",");

while(res!=NULL)
{
printf("%s\n",res);
dat[i]=res;
printf("%s\n",dat[i]);
i++;
res=strtok(NULL,",");
}
fclose(fptr);

getch();
}
]
 
Old 03-20-2009, 01:41 AM   #5
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
from the looks of it, its just a csv file, exported from excel, correct?
If you don't have constrain on the choice of language used (as in a homework), then just use a tool that helps you define rows and columns
Code:
awk 'NR==1{print $3}' csvfile
the awk code above prints row 1 column 3.
 
  


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
problem accessing files using samba vineet7kumar Linux - Software 1 08-13-2007 02:00 PM
problem accessing windows files the1wraith Linux - Networking 19 11-02-2005 12:35 PM
Database to Excel Files hategiants Linux - Software 4 07-27-2005 12:41 PM
Sharing Excel files in Linux cmdyer Linux - Newbie 4 06-30-2005 02:02 AM
Problem accessing files copied from CD to HD wildebs_27 Linux - Newbie 7 01-07-2005 06:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:53 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration