CSV to C structure utility

By Malcolm McLean Homepage

CSVtoC is a program that takes a CSV or comma-separated values file as input and dumps it as a C structure.

Missing strings are represented with null pointers, missing numbers by zero.

To use type
csvtoc infile.csv

Typical input file

     Name, "win loss", score
     Fred, 1, 0.3
     Jim, -3, 1
     Harry, 0, 0.1
    

Output

typedef struct
{
  char *Name;
  int win_loss;
  double score;
} TEAM;

TEAM team[3] =
{{"Fred",1,0.3,},
{"Jim",-3,1,},
{"Harry",0,0.1,},
};
    

Source Files

csvtoc.c
csv.c
csv.h


Last modified: Thu May 31 12:44:06 BST 2007