Dear Friends,
i have a senario where i am suppose to read the data from the CSV file(C,C++),and need to store
below is example
444444,TESCO,3WHEEL,SONY,,HIGH ( this is one record of a csv file)
i am using below code to store all the value, but not abe to store ",,"
void GetColumnValue( const char *lc_Record, char *Delim, char *pColmnName, long *FldCnt )
{
char Record[256] = {'\0'};
char ItemCd[16] = {'\0'};
char AttrVal[21] = {'\0'};<code></code>
char CompStr[1000] = {'\0'};
long ll_FldCnt = 0;
long ll_AttrNo = 0;
strcpy(Record,lc_Record);
char* p = strtok( Record, Delim );
while( p != NULL )
{
if(ll_FldCnt == 0)
{
strcpy(ItemCd,p);
strcat(ItemCd,",");
}
else
{
if( strlen(p) == 0 )
{
sprintf(gc_log, "There is no AttrValue in Request File For Itemcode %s and attrno %s",ItemCd, pConfigFile[ll_FldCnt].AttrNo );
LogInfo(gc_log);
continue;
}
strcpy(AttrVal,p);
TrimString( AttrVal, '\n',2 );
strcpy( CompStr, ItemCd );
strcat( CompStr, pConfigFile[ll_FldCnt].AttrNo );
strcat( CompStr,"," );
strcat( CompStr, AttrVal );
strcat( CompStr,"," );
strcat( CompStr, gc_sysDt );
strcat( CompStr,"," );
strcat( CompStr, g_user_name );
strcat( CompStr,"," );
strcat( CompStr, gc_sysDt );
strcat( CompStr,"," );
strcat( CompStr, g_user_name ); }
p=strtok( NULL,Delim);
if( ll_FldCnt != 0 )
fprintf( gp_RespFile,"%s\n",CompStr);
ll_FldCnt++;
strcpy( CompStr, "");
}
}
please let me know how to fix it
Kind regards,
praveer
[Edit]Adding Tag in proper way- johny[/Edit]