|
TPCCLIB
|
CSV struct processing. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <math.h>#include <time.h>#include <string.h>#include "tpccsv.h"Go to the source code of this file.
Functions | |
| void | csvInit (CSV *csv) |
| void | csvFree (CSV *csv) |
| int | csvAllocate (CSV *csv, int nr) |
| int | csvDuplicate (CSV *csv1, CSV *csv2) |
| Make a duplicate of CSV structure. | |
| int | csvPutString (CSV *csv, const char *s, int newline) |
| int | csvPutDouble (CSV *csv, double v, int newline, int tointl) |
| int | csvPutInt (CSV *csv, int v, int newline) |
| int | csvRowLength (CSV *csv, int row) |
| int | csvSetDimensions (CSV *csv) |
| int | csvIsRegular (CSV *csv) |
| int | csvTrimRight (CSV *csv) |
| char * | csvCell (CSV *csv, int row, int col) |
| int | csvCellReplace (CSV *csv, int row, int col, const char *s) |
| int | csvRemoveItem (CSV *csv, int i) |
| int | csvRemoveEmptyRows (CSV *csv) |
| int | csvRemoveComments (CSV *csv) |
| int | csvReorg (CSV *d, TPCSTATUS *status) |
| int | csvTranspose (CSV *csv) |
| int csvAllocate | ( | CSV * | csv, |
| int | nr ) |
Allocate memory for list of field items for CSV data.
Any previous content is preserved.
| csv | Pointer to CSV. |
| nr | Nr of field items to add to the list. |
Definition at line 58 of file csv.c.
Referenced by csvDuplicate(), csvPutString(), parWriteCSV(), and tacWriteCSV().
| char * csvCell | ( | CSV * | csv, |
| int | row, | ||
| int | col ) |
Get the CVS field contents in specified row and column.
Definition at line 358 of file csv.c.
Referenced by csvDuplicate(), csvRemoveEmptyRows(), csvWrite(), parReadFIT(), parReadRES(), tacRead(), tacReadCarimasTxt(), tacReadInveonCSV(), tacReadMat(), tacReadQView(), tacReadSIF(), and tacReadSimple().
| int csvCellReplace | ( | CSV * | csv, |
| int | row, | ||
| int | col, | ||
| const char * | s ) |
Replace the value of CVS field.
| csv | Pointer to CSV. |
| row | CSV row index. |
| col | CSV column index. |
| s | Field string to add; can be empty ("" or NULL). |
Definition at line 380 of file csv.c.
Make a duplicate of CSV structure.
Previous contents are copied. In the duplicate the space is allocated for row_nr times col_nr cells.
| csv1 | Pointer to the source CSV. |
| csv2 | Pointer to the target CSV; must be initiated; any old contents are deleted. |
| void csvFree | ( | CSV * | csv | ) |
Free memory allocated for CSV data. All contents are destroyed.
| csv | Pointer to CSV. |
Definition at line 38 of file csv.c.
Referenced by csvDuplicate(), parRead(), parWriteCSV(), tacRead(), and tacWriteCSV().
| void csvInit | ( | CSV * | csv | ) |
Initiate the CSV struct before any use.
| csv | Pointer to CSV. |
Definition at line 22 of file csv.c.
Referenced by csvFree(), parRead(), parWriteCSV(), tacFormatDetermine(), tacRead(), and tacWriteCSV().
| int csvIsRegular | ( | CSV * | csv | ) |
Check whether CSV is regular, that is, each row contain the same number of columns.
| csv | Pointer to CSV |
Definition at line 292 of file csv.c.
Referenced by tacRead(), tacReadMat(), and tacReadSimple().
| int csvPutDouble | ( | CSV * | csv, |
| double | v, | ||
| int | newline, | ||
| int | tointl ) |
Add specified double value as string into CSV.
| csv | Pointer to initiated CSV; previous contents are not changed. |
| v | Double value to add; NaN is added as an empty field. |
| newline | New line (1) or same line (0). |
| tointl | Convert (1) or do not convert (0) commas to semicolons and dots to commas. |
Definition at line 193 of file csv.c.
Referenced by parWriteCSV(), and tacWriteCSV().
| int csvPutInt | ( | CSV * | csv, |
| int | v, | ||
| int | newline ) |
Add specified integer value as string into CSV.
| csv | Pointer to initiated CSV; previous contents are not changed |
| v | Integer value to add; use csvPutString() to add an empty field |
| newline | New line (1) or same line (0) |
Definition at line 222 of file csv.c.
Referenced by parWriteCSV().
| int csvPutString | ( | CSV * | csv, |
| const char * | s, | ||
| int | newline ) |
Add specified string to CSV.
| csv | Pointer to initiated CSV; previous contents are not changed. |
| s | Field string to add; can be empty ("" or NULL). |
| newline | New line (1) or same line (0). |
Definition at line 144 of file csv.c.
Referenced by csvPutDouble(), csvPutInt(), csvPutLine(), csvPutLineWithSpaces(), parWriteCSV(), tacReadSIF(), and tacWriteCSV().
| int csvRemoveComments | ( | CSV * | csv | ) |
Remove those cells from CSV structure whose contents start with '#'.
| csv | Pointer to CSV. |
Definition at line 470 of file csv.c.
| int csvRemoveEmptyRows | ( | CSV * | csv | ) |
Remove empty rows from CSV. Rows that contain only empty cells or cells that start with '#' are considered empty.
| csv | Pointer to CSV. |
Definition at line 434 of file csv.c.
| int csvRemoveItem | ( | CSV * | csv, |
| int | i ) |
Remove item from CSV data structure.
| csv | Pointer to CSV. |
| i | Index of item to delete. |
Definition at line 409 of file csv.c.
Referenced by csvRemoveComments(), csvRemoveEmptyRows(), and csvTrimRight().
Sort CSV data array by increasing row and column numbers.
| d | Pointer to CSV structure. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 503 of file csv.c.
Referenced by csvTranspose(), and tacReadSIF().
| int csvRowLength | ( | CSV * | csv, |
| int | row ) |
Count the nr of columns on specified CSV row.
Definition at line 244 of file csv.c.
Referenced by csvWrite(), parReadFIT(), parReadRES(), tacReadDFT(), tacReadSIF(), and tacReadSimple().
| int csvSetDimensions | ( | CSV * | csv | ) |
Set the number of rows and columns in CSV table, based on the row and column stored with each cell. CSV may not be regular, thus maximum row and column numbers are used.
| csv | Pointer to CSV structure. |
Definition at line 269 of file csv.c.
Referenced by csvTranspose().
| int csvTranspose | ( | CSV * | csv | ) |
Transpose data in CSV structure.
To work properly, CSV should not contain comment cells/lines.
| csv | Pointer to CSV. |
Definition at line 530 of file csv.c.
| int csvTrimRight | ( | CSV * | csv | ) |
Remove empty cells from the right side of CVS table until a non-empty column is reached.
Resulting CSV may still not be regular.
| csv | Pointer to CSV |
Definition at line 321 of file csv.c.
Referenced by tacReadSimple().