예제 #1
0
/* csvtest main: test CSV library */
int main(void)
{
	int i;
	char *line;

	while ((line = csvgetline(stdin)) != NULL) {
	      printf("id = %s, Name = %s, nf = %d \n", csvfield(0), csvfield(1),csvnfield());
	}
	return 0;
}
예제 #2
0
/* Printing in JSON format to console */
void json_print(int x)
{
  int y;

  if (x != 1) printf("\n  },  \n");
  printf("  Row %d: {", x);

  for (y = 0; y < nfields - 2; y++) {
    printf("\n    %s: %s,", headers[y], csvfield(y));
  }

  printf("\n    %s: %s", headers[nfields-1], csvfield(nfields-1));
}
/* csvtest main: test CSV library */
int main(void)
{
	int i;
	char *line;

	csvinit(1000, 500);
	while ((line = csvgetline(stdin)) != NULL) {
		printf("line = `%s'\n", line);
		for (i = 0; i < csvnfield(); i++)
			printf("field[%d] = `%s'\n", i, csvfield(i));
	}
	return 0;
}
예제 #4
0
파일: main.c 프로젝트: ihilt/ref2mcg
static void print_result(FILE *fin, char *ref_des, char *cust_pn, char *mcg_pn)
{
	int i;
	int nfield;

	if (csvgetline(fin) != NULL) {
		if (ref_des_col > 0) {
			i = 0;
			while (i < ref_des_col+1)
				printf("%s,", csvfield(i++));
		} else {
			printf("%s,", ref_des == NULL ? "" : ref_des);
		}
		if (mcg_pn == NULL)
			printf("%s", cust_pn == NULL ? "" : cust_pn);
		else
			printf("%s", mcg_pn);
		nfield = csvnfield();
		for (i = ref_des_col + 1; i < nfield; i++)
			printf(",%s", csvfield(i));
		printf("\n");
	}
}
예제 #5
0
int main(void)
{
  int i;
  int x = 0;
  char *line;

  while ((line = csvgetline(stdin)) != NULL) {
    if (x == 0) {
      for (i = 0; i < csvnfield(); i++) {
        csvfield(i);
      }

      printf("{\n");
    } else {
      json_print(x);
    }

    if (x == 0) h_count = 1;
    x++;
  }

  printf("\n  }  \n}\n");
  return 0;
}