[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] adding --csv output

From: glpk xypron
Subject: Re: [Help-glpk] adding --csv output
Date: Sat, 15 Jan 2011 08:00:36 +0100

Hello Kevin, hello Andrew,

> Would further work on this patch be appreciated, or, more appropriately, 
> accepted?  Having CSV output would really help to more elegantly 
> streamline a couple of my workflows and needs.

As indicated I would rather avoid duplicate code
because it makes maintenance error prone.

If we want to follow the idea to change xfprintf to output CSV
the changes described below are necessary.

Andrew, could you, please, indicate what your thoughts about CSV
output are.

In glpenv.h:

A constant for csv files has to be added (after FH_FILE), e.g.
#define FH_FILE   0x11  /* FILE   */
#if 1 /* 16/I-2011 */
#define FH_CSV    0x12  /* CSV file */

In glpenv07.c:

xfopen has to be changed to set the type flag for csv if the filename
has extension ".csv", e.g.
#if 1 /* 16/I-2011 */
      char *ext = strrchr(fname, '.');
      type = FH_FILE;
      if (ext == NULL)
      } else if (strcmp(ext, ".gz") == 0)
      {  type = FH_ZLIB;
      } else if (strcmp(ext, ".csv") == 0)
      {  type = FH_CSV;
      if ( type != FH_ZLIB )
      {  fh = c_fopen(fname, mode);
      {  fh = z_fopen(fname, mode);
      if (!is_gz_file(fname))
      {  type = FH_FILE;
         fh = c_fopen(fname, mode);
      {  type = FH_ZLIB;
         fh = z_fopen(fname, mode);

xfgetc, xfputc, xferror, xfeof, xfflush, xfclose have to be changed
to treat csv files like FH_FILE, e.g.
      switch (fp->type)
      {  case FH_FILE:
#if 1 /* 16/I-2011 */
         case FH_CSV:

A replacement for xfprintf has to be written, that parses the printf
format string, csv escapes all strings, and inserts commas, if the
file type is csv.
is a good starting point for writing a parser for printf format strings.

The reference for the csv file format should be

Best regards

Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]