Just some thoughts or ideas please.
The following loop writes to a csv file. dates and times both equal three. Therefore when I open the csv file in excel there should be nothing past column 10. Then why, half way down the file, is a set of data put into columns 11 - 20? Since the input to the program is also csv files, I could be picking up an extra comma from the parsing routine. If anybody wants to throw out any ideas, it would be appreciated.
The following loop writes to a csv file. dates and times both equal three. Therefore when I open the csv file in excel there should be nothing past column 10. Then why, half way down the file, is a set of data put into columns 11 - 20? Since the input to the program is also csv files, I could be picking up an extra comma from the parsing routine. If anybody wants to throw out any ideas, it would be appreciated.
Code:
for ( i = 0; i < n; i++)
{
fprintf(outputfile, ",%s ", &ratios[i*pagesize]);
for (d = 1; d <=dates; d++)
for ( t=0; t< times;t++)
fprintf(outputfile,",%f",atof(&ratios[i*pagesize + (d)*rowsize + t*element]));
}
char ** parse( char *record, char *delim)
{
char **tarr;
char *p;
int i,fld=0;
if ( (p = (char *) calloc(element, sizeof(char))) == NULL)
printf("no memory for p");
tarr = (char **)calloc(100, sizeof(char*));
for (i = 0; i < 100; i ++)
{
if( (tarr[i] = (char*)calloc(element, sizeof(char))) == NULL)
printf("no memory allocated for arr\n");
}
p = strtok(record,delim);
while(p)
{
strcpy(tarr[fld],p);
fld++;
p=strtok('\0',delim);
}
return (tarr);
}