How to read a csv and extract some data

In reply to Anjali:

Not sure why you used $getc/$ungetc, snd you should be using $sscanf instead of $fscanf.

Also, it helps to put your question into a small complete example, like this:

module top;
   int fd;
   string c, str, ant;
   int num;
   initial begin
      if ((fd=$fopen("in.csv", "r")) != 0)
	while($fgets(str,fd) != 0) begin
	  if (str.match("ANT")) begin
	     // else: !if((fd=$fopen("in.csv", "r")) != 0)$sscanf(str, "%s %d", ant, num);
	     $display("%s :VALUE: %d", ant, num);
	  end

      end 
   end 
endmodule