Macros | Functions
import.c File Reference

Functions to read data files. More...

#include "libirt.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Macros

#define MAX_LINE_LENGTH   2000
 The maximum allowed length of a line.

Functions

int chomp (char *line)
 remove the newline (and possibly carriage return).
int count_lines (FILE *file)
 Count the number of line in file and then rewind.
int count_fields (FILE *file, int skip, char delimiter)
 Count the number of delimiter in the (skip+1) line of file and then rewind.
int trim (char *str)
 remove the spaces in a string.
int convert_delimited_bin (char *resp_str, char *true_string, char *false_string, char *blank_string)
 Convert the response string resp_str to integer.
int read_bin_patterns_delimited (FILE *file, int nbr_item, int nbr_subject, int skip, char delimiter, int offset, int extra, char *true_string, char *false_string, char *blank_string, int trimming, gsl_matrix_int **patterns)
 Read binary patterns from a file in delimited format.
int convert_delimited_mc (char *resp_str)
 Convert the multiple choice response string resp_str to integer.
int read_mc_patterns_delimited (FILE *file, int nbr_item, int nbr_subject, int skip, char delimiter, int offset, int extra, int trimming, gsl_matrix_int **patterns, gsl_vector_int **nbr_options)
 Read multiple choice patterns from a file in delimited format.

Detailed Description

Functions to read data files.

Author
Stephane Germain germs.nosp@m.te@g.nosp@m.mail..nosp@m.com

Macro Definition Documentation

#define MAX_LINE_LENGTH   2000

The maximum allowed length of a line.

Function Documentation

int chomp ( char *  line)

remove the newline (and possibly carriage return).

Parameters
[in,out]lineThe line to chomp.
Returns
The new length of the line.
int count_lines ( FILE *  file)

Count the number of line in file and then rewind.

Parameters
[in]fileThe file.
Returns
The number of lines.
int count_fields ( FILE *  file,
int  skip,
char  delimiter 
)

Count the number of delimiter in the (skip+1) line of file and then rewind.

Parameters
[in]fileThe file.
[in]skipThe number of line to skip.
[in]delimiterThe delimiter.
Returns
The number of delimiter in the line.
int trim ( char *  str)

remove the spaces in a string.

Parameters
[in,out]strThe string to trim.
Returns
The new length of the string.
int convert_delimited_bin ( char *  resp_str,
char *  true_string,
char *  false_string,
char *  blank_string 
)

Convert the response string resp_str to integer.

Parameters
[in]resp_strThe response string.
[in]true_stringThe string representing a success.
[in]false_stringThe string representing a failure or NULL.
[in]blank_stringThe string representing a non response or NULL.
Returns
If resp_str is true_str return TRUE else if resp_str is blank_str return BLANK else if resp_str is false_str return FALSE else if false_str is not NULL return BLANK else return FALSE.
int read_bin_patterns_delimited ( FILE *  file,
int  nbr_item,
int  nbr_subject,
int  skip,
char  delimiter,
int  offset,
int  extra,
char *  true_string,
char *  false_string,
char *  blank_string,
int  trimming,
gsl_matrix_int **  patterns 
)

Read binary patterns from a file in delimited format.

Parameters
[in]fileA open file descriptor with a rewind capability (not stdin).
[in]nbr_itemThe number of item to read or 0 for autodetection.
[in]nbr_subjectThe number of pattern to read or 0 for autodetection.
[in]skipThe number of line to skip at the start of the file.
[in]delimiterThe delimiter to use.
[in]offsetThe number of field to skip at the start of each line.
[in]extraThe number of field between the items.
[in]true_stringThe string representing a success.
[in]false_stringThe string representing a failure. If NULL then anything not a success nor a non response will be assume to be a failure.
[in]blank_stringThe string representing a non response. If NULL then anything not a success nor a failure will be assume to be a non response. A empty field is always assumed to be a non response.
[in]trimmingEnable the trimming of spaces.
[out]patternsA matrix(patterns x items) of binary responses.
Returns
1 for success and 0 for failure.
Warning
This function allocate the memory for patterns.
int convert_delimited_mc ( char *  resp_str)

Convert the multiple choice response string resp_str to integer.

Parameters
[in]resp_strThe response string.
Returns
If resp_str is a positive integer return this integer else return BLANK.
int read_mc_patterns_delimited ( FILE *  file,
int  nbr_item,
int  nbr_subject,
int  skip,
char  delimiter,
int  offset,
int  extra,
int  trimming,
gsl_matrix_int **  patterns,
gsl_vector_int **  nbr_options 
)

Read multiple choice patterns from a file in delimited format.

The responses are assumed to be positive integer, anything else will be assumed to be a non response.

Parameters
[in]fileA open file descriptor with a rewind capability (not stdin).
[in]nbr_itemThe number of item to read or 0 for autodetection.
[in]nbr_subjectThe number of pattern to read or 0 for autodetection.
[in]skipThe number of line to skip at the start of the file.
[in]delimiterThe delimiter to use.
[in]offsetThe number of field to skip at the start of each line.
[in]extraThe number of field to ignore after each items.
[in]trimmingEnable the trimming of spaces.
[out]patternsA matrix(patterns x items) of mc responses.
[out]nbr_optionsA vector(items) with the number of option of each item in patterns (and probs).
Returns
1 for success and 0 for failure.
Warning
This function allocate the memory for patterns and nbr_options.

SourceForge.net Logo Generated on Sun Jan 26 2014 15:27:27 for libirt by Doxygen. Valid HTML 4.01 Transitional