static int handle_variable(int index, readstat_variable_t *variable, const char *val_labels, void *ctx) { mod_csv_ctx_t *mod_ctx = (mod_csv_ctx_t *)ctx; const char *name = readstat_variable_get_name(variable); if (index > 0) { fprintf(mod_ctx->out_file, ",\"%s\"", name); } else { fprintf(mod_ctx->out_file, "\"%s\"", name); } if (index == mod_ctx->var_count - 1) { fprintf(mod_ctx->out_file, "\n"); } return 0; }
static int handle_variable(int index, readstat_variable_t *variable, const char *val_labels, void *ctx) { rs_ctx_t *rs_ctx = (rs_ctx_t *)ctx; readstat_writer_t *writer = rs_ctx->writer; readstat_types_t type = readstat_variable_get_type(variable); const char *name = readstat_variable_get_name(variable); const char *label = readstat_variable_get_label(variable); char *format = NULL; size_t width = readstat_variable_get_width(variable); readstat_label_set_t *label_set = NULL; if (val_labels) { label_set = (readstat_label_set_t *)ck_str_hash_lookup(val_labels, rs_ctx->label_set_dict); } readstat_add_variable(writer, type, width, name, label, format, label_set); return 0; }