LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   problem in accessing excel files (https://www.linuxquestions.org/questions/programming-9/problem-in-accessing-excel-files-712770/)

MiniGopal 03-19-2009 05:26 AM

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....

theNbomr 03-19-2009 07:55 PM

Quote:

Originally Posted by MiniGopal (Post 3480497)
can anyone help me.....

Only if you show the code...
(don't forget, in [CODE] tags, please).
--- rod.

paulsm4 03-19-2009 09:35 PM

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

MiniGopal 03-20-2009 01:36 AM

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();
}
]

ghostdog74 03-20-2009 01:41 AM

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.


All times are GMT -5. The time now is 01:34 PM.