q-lang-cvs Mailing List for Q - Equational Programming Language (Page 8)
Brought to you by:
agraef
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(106) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(219) |
Feb
(152) |
Mar
|
Apr
(92) |
May
(45) |
Jun
(3) |
Jul
|
Aug
(3) |
Sep
(111) |
Oct
(52) |
Nov
|
Dec
|
2005 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(23) |
Jun
(46) |
Jul
(158) |
Aug
(22) |
Sep
|
Oct
(26) |
Nov
(11) |
Dec
(49) |
2006 |
Jan
(57) |
Feb
(196) |
Mar
(10) |
Apr
(41) |
May
(149) |
Jun
(308) |
Jul
(11) |
Aug
(25) |
Sep
(15) |
Oct
|
Nov
|
Dec
(15) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(15) |
May
(204) |
Jun
(112) |
Jul
(7) |
Aug
(16) |
Sep
(134) |
Oct
(313) |
Nov
(262) |
Dec
(83) |
2008 |
Jan
(81) |
Feb
(83) |
Mar
(21) |
Apr
|
May
|
Jun
(1) |
Jul
(2) |
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Albert G. <ag...@us...> - 2008-01-14 06:43:13
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9772 Modified Files: README Log Message: overhaul the description of the primary interface functions and error handling Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** README 14 Jan 2008 04:35:30 -0000 1.8 --- README 14 Jan 2008 06:43:09 -0000 1.9 *************** *** 28,37 **** - freadcsv_data converts non-quoted numeric fields to integer or double values ! automatically. Invalidly formatted CSV strings force the invocation of a ! 'csv_error MSG' rule. fwritecsv_data writes integer or double values to non-quoted fields. The handling of quoted or non-quoted fields is automatic. Fields with types ! other than floats, integers or strings force the invocation of a ! 'csv_error MSG' rule. - freadcsv_string and fwritecsv_string read all fields as strings --- 28,37 ---- - freadcsv_data converts non-quoted numeric fields to integer or double values ! automatically. Invalidly formatted CSV causes return of a 'csv_error MSG' ! term (see NOTES below). fwritecsv_data writes integer or double values to non-quoted fields. The handling of quoted or non-quoted fields is automatic. Fields with types ! other than floats, integers or strings cause return of a 'csv_error MSG' ! term (see NOTES below). - freadcsv_string and fwritecsv_string read all fields as strings *************** *** 39,46 **** fwritecsv_string writes all values as quoted fields. ! The primary interface function fread_csvstr reads a string from a file ! with embedded end of lines. It does not check for a valid record. The two ! other primary interface functions, csvstr_to_tuple and tuple_to_csvstr ! convert CSV formatted strings to tuples and vice versa. The routines described above read/write one record at a time. Additional --- 39,54 ---- fwritecsv_string writes all values as quoted fields. ! The above routines are defined in terms of the following primary interface ! functions fread_csvstr, csvstr_to_tuple and tuple_to_csvstr: ! ! - fread_csvstr reads a single CSV record from a file. This essentially works ! like freads, but handles quoted newlines embedded in a field value. Note ! that fread_csvstr does *not* verify that the string actually conforms to CSV ! syntax. ! ! - csvstr_to_tuple and tuple_to_csvstr convert CSV formatted strings to tuples ! and vice versa. These functions check for correct CSV syntax and proper ! field values, respectively, and return a 'csv_error MSG' term in case of an ! error condition (see NOTES below). The routines described above read/write one record at a time. Additional *************** *** 51,64 **** NOTES ! - The read functions fail when reading records that do not abide by the RFC ! 4180 rules. ! - The write functions fail when field types other than strings, integers, or ! floats are given. ! - MS Excel files should be read using _string variants as Excel does not quote ! values such as 0004. These types of values will be converted to integers and ! the leading significant 0s will be lost. Significant leading or trailing ! space may likewise be lost without using the _string variant. TO DO --- 59,76 ---- NOTES ! - Errors in the conversion routines (input strings that do not abide by the ! RFC 4180 rules; records containing field types other than strings, integers ! and floats) cause a special 'csv_error MSG' term to be returned, where MSG ! is a string describing the particular error. To handle error conditions, ! your application should either check for these, or define csv_error to ! directly handle the error in some way (e.g., provide a default value, or ! raise an exception). For instance: ! csv_error MSG = throw MSG; ! - MS Excel files should be read using the _string variants as Excel does not ! quote values such as 0004. These types of values will be converted to ! integers and the leading significant 0s will be lost. Significant leading or ! trailing space may likewise be lost without using the _string variant. TO DO |
From: Albert G. <ag...@us...> - 2008-01-14 06:15:22
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8888 Modified Files: csv.c Log Message: must test for null char instead of EOF to determine string end Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** csv.c 14 Jan 2008 04:41:33 -0000 1.8 --- csv.c 14 Jan 2008 06:15:17 -0000 1.9 *************** *** 167,171 **** } else if (!strncmp(sp, strdl, 1)) { goto st1; ! } else if (*sp == '\n' || *sp == EOF) { putrec(FORCEQUOTE); goto st10; --- 167,171 ---- } else if (!strncmp(sp, strdl, 1)) { goto st1; ! } else if (*sp == '\n' || *sp == 0) { putrec(FORCEQUOTE); goto st10; *************** *** 180,184 **** if (!strncmp(sp, strdl, 1)) { goto st2; ! } else if (*sp == EOF) { goto st20; } else { --- 180,184 ---- if (!strncmp(sp, strdl, 1)) { goto st2; ! } else if (*sp == 0) { goto st20; } else { *************** *** 193,197 **** putrec(FORCEQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { putrec(FORCEQUOTE); goto st10; --- 193,197 ---- putrec(FORCEQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == 0) { putrec(FORCEQUOTE); goto st10; *************** *** 206,210 **** putrec(FORCEQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { putrec(FORCEQUOTE); goto st10; --- 206,210 ---- putrec(FORCEQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == 0) { putrec(FORCEQUOTE); goto st10; *************** *** 219,223 **** putrec(AUTOQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { putrec(AUTOQUOTE); goto st10; --- 219,223 ---- putrec(AUTOQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == 0) { putrec(AUTOQUOTE); goto st10; *************** *** 238,242 **** putrec(AUTOQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { fieldp -= ws_cnt; /* get rid of ws at the end of the field */ putrec(AUTOQUOTE); --- 238,242 ---- putrec(AUTOQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == 0) { fieldp -= ws_cnt; /* get rid of ws at the end of the field */ putrec(AUTOQUOTE); |
From: Albert G. <ag...@us...> - 2008-01-14 04:41:38
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10534 Modified Files: csv.c Log Message: typo fixes Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** csv.c 14 Jan 2008 04:28:02 -0000 1.7 --- csv.c 14 Jan 2008 04:41:33 -0000 1.8 *************** *** 122,126 **** input: arg[0]: (Conversion flag, field delimeter char, string delimeter char) ! arg[1]: CSV formated string output: tuple of fields --- 122,126 ---- input: arg[0]: (Conversion flag, field delimeter char, string delimeter char) ! arg[1]: CSV formatted string output: tuple of fields *************** *** 128,132 **** exceptions: Returns __ERROR if no more memory is available. ! Invokes 'csv_error MSG' if the string is badly formated Notes: --- 128,132 ---- exceptions: Returns __ERROR if no more memory is available. ! Invokes 'csv_error MSG' if the string is badly formatted Notes: *************** *** 293,297 **** arg[1]: tuple to be converted ! output: CSV formated string exceptions: --- 293,297 ---- arg[1]: tuple to be converted ! output: CSV formatted string exceptions: |
From: Albert G. <ag...@us...> - 2008-01-14 04:35:36
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1887 Modified Files: README Log Message: typo fixes Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** README 13 Jan 2008 17:27:14 -0000 1.7 --- README 14 Jan 2008 04:35:30 -0000 1.8 *************** *** 28,36 **** - freadcsv_data converts non-quoted numeric fields to integer or double values ! automatically. Invalidly formated CSV strings force the invocation of a 'csv_error MSG' rule. fwritecsv_data writes integer or double values to non-quoted fields. The handling of quoted or non-quoted fields is automatic. Fields with types ! other than floats, integers, or strings force the invocation of a 'csv_error MSG' rule. --- 28,36 ---- - freadcsv_data converts non-quoted numeric fields to integer or double values ! automatically. Invalidly formatted CSV strings force the invocation of a 'csv_error MSG' rule. fwritecsv_data writes integer or double values to non-quoted fields. The handling of quoted or non-quoted fields is automatic. Fields with types ! other than floats, integers or strings force the invocation of a 'csv_error MSG' rule. *************** *** 42,49 **** with embedded end of lines. It does not check for a valid record. The two other primary interface functions, csvstr_to_tuple and tuple_to_csvstr ! convert CSV formated strings to tuples and vice versa. The routines described above read/write one record at a time. Additional ! functions (freadfilecsv_data and fwritefilecsv_data) are provided to convert between entire CSV files and lists of tuples. Note that these require that the entire data fits into RAM and will thus be inefficient for huge datasets. --- 42,49 ---- with embedded end of lines. It does not check for a valid record. The two other primary interface functions, csvstr_to_tuple and tuple_to_csvstr ! convert CSV formatted strings to tuples and vice versa. The routines described above read/write one record at a time. Additional ! functions (freadcsvfile_data and fwritecsvfile_data) are provided to convert between entire CSV files and lists of tuples. Note that these require that the entire data fits into RAM and will thus be inefficient for huge datasets. |
From: Albert G. <ag...@us...> - 2008-01-14 04:28:11
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24085 Modified Files: csv.c csv.q Log Message: add cvs id Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** csv.c 14 Jan 2008 04:26:21 -0000 1.6 --- csv.c 14 Jan 2008 04:28:02 -0000 1.7 *************** *** 15,18 **** --- 15,19 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + $Id$ Written by Eddie Rucker 3-13 Jan, 2008 */ Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** csv.q 13 Jan 2008 21:40:50 -0000 1.8 --- csv.q 14 Jan 2008 04:28:03 -0000 1.9 *************** *** 16,19 **** --- 16,21 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + /* $Id$ */ + /* The CSV library provides an interface to read and write comma separated value files. The reading and writing functions abide by RFC 4180 |
From: Albert G. <ag...@us...> - 2008-01-14 04:26:29
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22082 Modified Files: csv.c Log Message: optimization Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** csv.c 14 Jan 2008 04:23:43 -0000 1.5 --- csv.c 14 Jan 2008 04:26:21 -0000 1.6 *************** *** 56,60 **** bp = buff + len; } ! if (c == '\n' && !(q_cnt % 2)) break; if (c == *strdl) --- 56,60 ---- bp = buff + len; } ! if (c == '\n' && !(q_cnt & 1)) break; if (c == *strdl) |
From: Albert G. <ag...@us...> - 2008-01-14 04:23:50
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17819 Modified Files: csv.c Log Message: add unicode support Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** csv.c 13 Jan 2008 17:27:14 -0000 1.4 --- csv.c 14 Jan 2008 04:23:43 -0000 1.5 *************** *** 34,38 **** { FILE *fp; ! char *buff, *bp, *tp, *strdl; int len = 0, q_cnt = 0, size = BSIZE; register int c; --- 34,38 ---- { FILE *fp; ! char *buff, *bp, *tp, *strdl, *s; int len = 0, q_cnt = 0, size = BSIZE; register int c; *************** *** 63,70 **** *bp++ = c; } - buff = (char *)realloc(buff, len+2); *bp++ = c; *bp = 0; ! return mkstr(buff); } --- 63,74 ---- *bp++ = c; } *bp++ = c; *bp = 0; ! s = to_utf8(buff, NULL); ! free(buff); ! if (s) ! return mkstr(s); ! else ! return __ERROR; } |
From: Albert G. <ag...@us...> - 2008-01-13 21:40:54
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4136 Modified Files: csv.q Log Message: fix comment Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** csv.q 13 Jan 2008 21:38:45 -0000 1.7 --- csv.q 13 Jan 2008 21:40:50 -0000 1.8 *************** *** 44,48 **** /* Convert CSV string to a tuple (record). ARGS: tuple (auto conversion flag, field delimiter, string delimiter) ! STR: tuple of fields to be converted to CSV format NOTES --- 44,48 ---- /* Convert CSV string to a tuple (record). ARGS: tuple (auto conversion flag, field delimiter, string delimiter) ! STR: CSV string to be converted to a tuple NOTES |
From: Albert G. <ag...@us...> - 2008-01-13 21:38:59
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1459 Modified Files: csv.q Log Message: more typo fixes Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** csv.q 13 Jan 2008 21:31:11 -0000 1.6 --- csv.q 13 Jan 2008 21:38:45 -0000 1.7 *************** *** 68,72 **** freadcsv_string F:File = csvstr_to_tuple (false, "," "\"") (fread_csvstr F "\""); ! freadcsv_string_data (F:File, FieldDelim:String, StrDelim:String) = csvstr_to_tuple (false, "," "\"") (fread_csvstr F StrDelim); --- 68,72 ---- freadcsv_string F:File = csvstr_to_tuple (false, "," "\"") (fread_csvstr F "\""); ! freadcsv_string (F:File, FieldDelim:String, StrDelim:String) = csvstr_to_tuple (false, "," "\"") (fread_csvstr F StrDelim); *************** *** 92,108 **** freadcsvfile_data F:File = [] if feof F; ! = [freadscsv_data F | freadcsvfile_data F]; freadcsvfile_data (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadscsv_data (F, FieldDelim, StrDelim) | freadcsvfile_data F]; freadcsvfile_string F:File = [] if feof F; ! = [freadscsv_string F | freadcsvfile_dara F]; freadcsvfile_string (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadscsv_string (F, FieldDelim, StrDelim) | freadcsvfile_string F]; ! public fwritecsvfile_data FILE LIST, fwritefile_string ARGS; /* Write a list of tuples to a CSV formatted file. */ --- 92,108 ---- freadcsvfile_data F:File = [] if feof F; ! = [freadcsv_data F | freadcsvfile_data F]; freadcsvfile_data (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadcsv_data (F, FieldDelim, StrDelim) | freadcsvfile_data F]; freadcsvfile_string F:File = [] if feof F; ! = [freadcsv_string F | freadcsvfile_data F]; freadcsvfile_string (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadcsv_string (F, FieldDelim, StrDelim) | freadcsvfile_string F]; ! public fwritecsvfile_data FILE LIST, fwritecsvfile_string ARGS; /* Write a list of tuples to a CSV formatted file. */ |
From: Albert G. <ag...@us...> - 2008-01-13 21:31:15
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22873 Modified Files: csv.q Log Message: typo fixes Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** csv.q 13 Jan 2008 17:27:14 -0000 1.5 --- csv.q 13 Jan 2008 21:31:11 -0000 1.6 *************** *** 26,35 **** STRDELIM: string delimiter used in the CSV format ! NOTE: fread_csvstr does not take into account badly formated records. csvstr_to_tuple is necessary for error checking. */ public extern tuple_to_csvstr ARGS REC; ! /* Convert a tuple (record) to CSV string ARGS: tuple (auto conversion flag, field delimiter, string delimiter) REC: tuple of fields to be converted to CSV format --- 26,35 ---- STRDELIM: string delimiter used in the CSV format ! NOTE: fread_csvstr does not take into account badly formatted records. csvstr_to_tuple is necessary for error checking. */ public extern tuple_to_csvstr ARGS REC; ! /* Convert a tuple (record) to a CSV string ARGS: tuple (auto conversion flag, field delimiter, string delimiter) REC: tuple of fields to be converted to CSV format *************** *** 47,53 **** NOTES ! (1) A properly formated CSV string MUST end with a '\n' ! (2) When the auto conversion flag is false, All fields are strings. ! (3) The 'csv_error MSG' rule is invoked on improperly formated strings. */ --- 47,53 ---- NOTES ! (1) A properly formated CSV string MUST end with a '\n'. ! (2) When the auto conversion flag is false, all fields are strings. ! (3) The 'csv_error MSG' rule is invoked on improperly formatted strings. */ *************** *** 105,109 **** public fwritecsvfile_data FILE LIST, fwritefile_string ARGS; ! /* Write a list of tuples to a CSV formated file. */ fwritecsvfile_data F:File L:List --- 105,109 ---- public fwritecsvfile_data FILE LIST, fwritefile_string ARGS; ! /* Write a list of tuples to a CSV formatted file. */ fwritecsvfile_data F:File L:List |
From: Albert G. <ag...@us...> - 2008-01-13 21:02:52
|
Update of /cvsroot/q-lang/q/doc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6608 Modified Files: qdoc.texi version.texi Log Message: clarify status of builtin stream constants, as suggested by Rob Hubbard Index: qdoc.texi =================================================================== RCS file: /cvsroot/q-lang/q/doc/qdoc.texi,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** qdoc.texi 20 Oct 2007 10:07:43 -0000 1.138 --- qdoc.texi 13 Jan 2008 21:02:44 -0000 1.139 *************** *** 6437,6441 **** The constant symbol @code{nil_stream} denotes an empty stream, while the special constructor symbol @code{cons_stream} is used to represent a ! nonempty stream with head @code{X} and tail @code{Xs}. As of Q 7.1, the language also provides some syntactic sugar for these constructs to make them look more list-like. In particular, @code{@{@}} is the same as --- 6437,6443 ---- The constant symbol @code{nil_stream} denotes an empty stream, while the special constructor symbol @code{cons_stream} is used to represent a ! nonempty stream with head @code{X} and tail @code{Xs}. (Please note ! that, as of Q 7.1, these symbols are now builtins and thus cannot be ! imported from the @code{stream.q} module any more.) As of Q 7.1, the language also provides some syntactic sugar for these constructs to make them look more list-like. In particular, @code{@{@}} is the same as Index: version.texi =================================================================== RCS file: /cvsroot/q-lang/q/doc/version.texi,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** version.texi 17 Dec 2007 22:05:41 -0000 1.92 --- version.texi 13 Jan 2008 21:02:44 -0000 1.93 *************** *** 1,4 **** ! @set UPDATED 20 October 2007 ! @set UPDATED-MONTH October 2007 @set EDITION 7.10 @set VERSION 7.10 --- 1,4 ---- ! @set UPDATED 13 January 2008 ! @set UPDATED-MONTH January 2008 @set EDITION 7.10 @set VERSION 7.10 |
From: RER <ed...@us...> - 2008-01-13 17:27:22
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31912 Modified Files: README csv.c csv.q Log Message: updated README, read samples, write samples, csv.c, and csv.q Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** README 10 Jan 2008 23:41:21 -0000 1.6 --- README 13 Jan 2008 17:27:14 -0000 1.7 *************** *** 28,34 **** - freadcsv_data converts non-quoted numeric fields to integer or double values ! automatically. fwritecsv_data writes integer or double values to non-quoted fields. The ! handling of quoted or non-quoted fields is handled automatically. - freadcsv_string and fwritecsv_string read all fields as strings --- 28,37 ---- - freadcsv_data converts non-quoted numeric fields to integer or double values ! automatically. Invalidly formated CSV strings force the invocation of a ! 'csv_error MSG' rule. fwritecsv_data writes integer or double values to non-quoted fields. The ! handling of quoted or non-quoted fields is automatic. Fields with types ! other than floats, integers, or strings force the invocation of a ! 'csv_error MSG' rule. - freadcsv_string and fwritecsv_string read all fields as strings *************** *** 36,51 **** fwritecsv_string writes all values as quoted fields. ! The primary interface functions freadcsv and fwritecsv are defined to be ! equivalent to the _data variants by default. If necessary, you can change this ! by adding appropriate definitions to your program, i.e.: ! ! freadcsv = freadcsv_string; ! fwritecsv = fwritecsv_string; The routines described above read/write one record at a time. Additional ! functions (freadfilecsv and fwritefilecsv, again with corresponding _data and ! _string variants) are provided to convert between entire CSV files and lists ! of tuples. Note that these require that the entire data fits into RAM and will ! thus be inefficient for huge datasets. NOTES --- 39,51 ---- fwritecsv_string writes all values as quoted fields. ! The primary interface function fread_csvstr reads a string from a file ! with embedded end of lines. It does not check for a valid record. The two ! other primary interface functions, csvstr_to_tuple and tuple_to_csvstr ! convert CSV formated strings to tuples and vice versa. The routines described above read/write one record at a time. Additional ! functions (freadfilecsv_data and fwritefilecsv_data) are provided to convert ! between entire CSV files and lists of tuples. Note that these require that ! the entire data fits into RAM and will thus be inefficient for huge datasets. NOTES *************** *** 54,57 **** --- 54,60 ---- 4180 rules. + - The write functions fail when field types other than strings, integers, or + floats are given. + - MS Excel files should be read using _string variants as Excel does not quote values such as 0004. These types of values will be converted to integers and *************** *** 61,67 **** TO DO - - String to Tuple and Tuple to String versions corresponding to the reading - and writing operations will be provided. - - Operations for fixed length record reading and writing will be provided. --- 64,67 ---- Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** csv.c 12 Jan 2008 13:37:49 -0000 1.3 --- csv.c 13 Jan 2008 17:27:14 -0000 1.4 *************** *** 1,3 **** ! /* CSV according to RFC 4180 (http://www.ietf.org/rfc/rfc4180.txt) This is free software; you can redistribute it and/or --- 1,3 ---- ! /* CSV according to RFC 4180 (http://tools.ietf.rg/html/rfc4180) This is free software; you can redistribute it and/or *************** *** 16,22 **** ! Written by Eddie Rucker 3-12 Jan, 2008 */ ! ! /* Test to see if cvs is working */ #include <stdio.h> --- 16,20 ---- ! Written by Eddie Rucker 3-13 Jan, 2008 */ #include <stdio.h> *************** *** 24,33 **** #include <libq.h> #define FORCEQUOTE 0 ! #define AUTOQUOTE 1 - MODULE(csv); /* convience function to convert numbers */ expr *convert(char *s, int cvt_flag) { long i; --- 22,75 ---- #include <libq.h> + MODULE(csv); + + #define BSIZE 512 #define FORCEQUOTE 0 ! #define AUTOQUOTE 1 ! ! /* fread_block reads embbeded '\n's ! Does not account for badly formatted records */ ! ! FUNCTION (csv, fread_csvstr, argc, argv) ! { ! FILE *fp; ! char *buff, *bp, *tp, *strdl; ! int len = 0, q_cnt = 0, size = BSIZE; ! register int c; ! ! if (argc != 2 ! || !isfile(argv[0], &fp) ! || !isstr(argv[1], &strdl)) ! return __FAIL; ! ! if (!(buff = (char *)malloc(size))) ! return NULL; ! ! bp = buff; ! while ((c = fgetc(fp)) != EOF) { ! if (len > size) { ! if (!(tp = (char *)realloc(buff, size <<= 1))) { ! free(buff); ! return __ERROR; ! } ! buff = tp; ! bp = buff + len; ! } ! if (c == '\n' && !(q_cnt % 2)) ! break; ! if (c == *strdl) ! ++q_cnt; ! ++len; ! *bp++ = c; ! } ! buff = (char *)realloc(buff, len+2); ! *bp++ = c; ! *bp = 0; ! return mkstr(buff); ! } /* convience function to convert numbers */ + expr *convert(char *s, int cvt_flag) { long i; *************** *** 48,118 **** } ! #define putfld \ ! if (fld_len >= fld_size - 1) { \ ! if (!(tfield = realloc(field, fld_size <<= 1))) \ ! goto st30; \ ! field = tfield; \ ! } \ ! sp = field + fld_len++; \ ! *sp++ = c /* force == 0 forces the field to be quoted */ #define putrec(force) \ ! *sp = 0; \ if (rec_len >= rec_size - 1) { \ ! if (!(trec = realloc(rec, (rec_size += 16)*sizeof(expr)))) \ goto st30; \ rec = trec; \ } \ ! if ((rec[rec_len++] = convert(field, cvt_flag&force)) == NULL) \ goto st30 ! /* freadcsv_ ! input: (Conversion flag, File, field delimeter char, string delimeter char) ! output: tuple of fields. Notes: ! \r char is treated as white space except inside "" ! */ ! FUNCTION(csv, freadcsv_, argc, argv) ! { ! FILE *fp; ! char *field, *tfield, *sp, *fld_dlm, *str_dlm; ! int n, fld_size = 128, fld_len, rec_size = 128, ws_cnt = 0, rec_len = 0, ! cvt_flag, exit_type = 0; ! register int c; ! expr *rec, *trec, *xs; ! if (argc != 1 || !istuple(argv[0], &n, &xs) ! || n != 4 ! || !isbool(xs[0], &cvt_flag) ! || !isfile(xs[1], &fp) ! || !isstr(xs[2], &fld_dlm) ! || !isstr(xs[3], &str_dlm)) return __FAIL; ! ! if (!(field = malloc(fld_size))) return __ERROR; ! ! if (!(rec = malloc(rec_size*sizeof(expr)))) { free(field); return __ERROR; } ! ! st0: c = fgetc(fp); ! sp = field; fld_len = 0; ! if (c == *fld_dlm) { putrec(FORCEQUOTE); goto st0; ! } else if (c == *str_dlm) { goto st1; ! } else if (c == '\n' || c == EOF) { putrec(FORCEQUOTE); goto st10; ! } else if (c == ' ' || c == '\t' || c == '\r') { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ goto st0; --- 90,169 ---- } ! ! #define putfld \ ! if (fld_len >= fld_size - 1) { \ ! if (!(tfield = (char *)realloc(field, fld_size <<= 1))) \ ! goto st30; \ ! field = tfield; \ ! } \ ! fieldp = field + fld_len++; \ ! *fieldp++ = *sp ! /* force == 0 forces the field to be quoted */ + #define putrec(force) \ ! *fieldp = 0; \ if (rec_len >= rec_size - 1) { \ ! if (!(trec = (expr *)realloc(rec, (rec_size += 16)*sizeof(expr)))) \ goto st30; \ rec = trec; \ } \ ! if ((rec[rec_len++] = convert(field, cvt_f&force)) == NULL) \ goto st30 ! /* convert a CSV string to a tuple of fields ! input: ! arg[0]: (Conversion flag, field delimeter char, string delimeter char) ! arg[1]: CSV formated string ! ! output: tuple of fields ! exceptions: ! Returns __ERROR if no more memory is available. ! Invokes 'csv_error MSG' if the string is badly formated Notes: ! \r char is treated as white space except inside "" */ ! FUNCTION(csv, csvstr_to_tuple, argc, argv) ! { ! int n, cvt_f, fld_size = 256, fld_len, rec_size = 64, ws_cnt = 0, ! rec_len = 0, exit_type = 0; ! char *field, *tfield, *fieldp, *s, *flddl, *strdl, errmsg[80]; ! expr *xs, *rec, *trec; ! register char *sp; ! ! if (argc != 2 || !istuple(argv[0], &n, &xs) ! || n != 3 ! || !isbool(xs[0], &cvt_f) ! || !isstr(xs[1], &flddl) ! || !isstr(xs[2], &strdl) ! || !isstr(argv[1], &s)) return __FAIL; ! ! if (!(field = (char *)malloc(fld_size))) return __ERROR; ! ! if (!(rec = (expr *)malloc(rec_size*sizeof(expr)))) { free(field); return __ERROR; } ! ! sp = s - 1; ! st0: ++sp; ! fieldp = field; fld_len = 0; ! if (!strncmp(sp, flddl, 1)) { putrec(FORCEQUOTE); goto st0; ! } else if (!strncmp(sp, strdl, 1)) { goto st1; ! } else if (*sp == '\n' || *sp == EOF) { putrec(FORCEQUOTE); goto st10; ! } else if (isspace(*sp)) { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ goto st0; *************** *** 121,129 **** goto st4; } ! st1: c = fgetc(fp); ! if (c == *str_dlm) { goto st2; ! } ! else if (c == EOF) { goto st20; } else { --- 172,179 ---- goto st4; } ! st1: ++sp; ! if (!strncmp(sp, strdl, 1)) { goto st2; ! } else if (*sp == EOF) { goto st20; } else { *************** *** 131,145 **** goto st1; } ! st2: c = fgetc(fp); ! if (c == *str_dlm) { putfld; goto st1; ! } else if (c == *fld_dlm) { putrec(FORCEQUOTE); goto st0; ! } else if (c == '\n' || c == EOF) { putrec(FORCEQUOTE); goto st10; ! } else if (c == ' ' || c == '\t' || c == '\r') { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ goto st3; --- 181,195 ---- goto st1; } ! st2: ++sp; ! if (!strncmp(sp, strdl, 1)) { putfld; goto st1; ! } else if (!strncmp(sp, flddl, 1)) { putrec(FORCEQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { putrec(FORCEQUOTE); goto st10; ! } else if (isspace(*sp)) { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ goto st3; *************** *** 147,171 **** goto st20; } ! st3: c = fgetc(fp); ! if (c == *fld_dlm) { putrec(FORCEQUOTE); goto st0; ! } else if (c == '\n' || c == EOF) { putrec(FORCEQUOTE); goto st10; ! } else if (c == ' ' || c == '\t' || c == '\r') { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ goto st3; } ! st4: c = fgetc(fp); ! if (c == *fld_dlm) { putrec(AUTOQUOTE); goto st0; ! } else if (c == '\n' || c == EOF) { putrec(AUTOQUOTE); goto st10; ! } else if (c == *str_dlm) { goto st20; ! } else if (c == ' ' || c == '\t' || c == '\r') { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ ws_cnt = 1; --- 197,223 ---- goto st20; } ! st3: ++sp; ! if (!strncmp(sp, flddl, 1)) { putrec(FORCEQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { putrec(FORCEQUOTE); goto st10; ! } else if (isspace(*sp)) { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ goto st3; + } else { + goto st20; } ! st4: ++sp; ! if (!strncmp(sp, flddl, 1)) { putrec(AUTOQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { putrec(AUTOQUOTE); goto st10; ! } else if (!strncmp(sp, strdl, 1)) { goto st20; ! } else if (isspace(*sp)) { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ ws_cnt = 1; *************** *** 176,189 **** goto st4; } ! st5: c = fgetc(fp); ! if (c == *fld_dlm) { ! sp -= ws_cnt; /* get rid of ws at the end of the field */ putrec(AUTOQUOTE); goto st0; ! } else if (c == '\n' || c == EOF) { ! sp -= ws_cnt; /* get rid of ws at the end of the field */ putrec(AUTOQUOTE); goto st10; ! } else if (c == ' ' || c == '\t' || c == '\r') { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ ++ws_cnt; --- 228,241 ---- goto st4; } ! st5: ++sp; ! if (!strncmp(sp, flddl, 1)) { ! fieldp -= ws_cnt; /* get rid of ws at the end of the field */ putrec(AUTOQUOTE); goto st0; ! } else if (*sp == '\n' || *sp == EOF) { ! fieldp -= ws_cnt; /* get rid of ws at the end of the field */ putrec(AUTOQUOTE); goto st10; ! } else if (isspace(*sp)) { /* fld_dlm might be ws make sure it is after (c == *fld_dlm) */ ++ws_cnt; *************** *** 205,298 **** dispose(rec[n]); free(rec); ! if (exit_type == 1) ! return __FAIL; return __ERROR; } ! /* fwritecsv_ - input: (Conversion Flag, File, field delimeter char, string delimeter char) - Tuple - output: File. ! returns: ! __FAIL if arguments are not valid. ! __ERROR is out of memory ! */ ! FUNCTION (csv, fwritecsv_, argc, argv) { ! FILE *fp; ! int i, n, dqflag, qcnt = 0, cvt_flag; long ival; double dval; - char *fld_del, *str_del, *sval, *prt, *rt; - register char *t; expr *xs, *ys; if (argc != 2 || !istuple(argv[0], &i, &ys) ! || i != 4 ! || !isbool(ys[0], &cvt_flag) ! || !isfile(ys[1], &fp) ! || !isstr(ys[2], &fld_del) ! || !isstr(ys[3], &str_del) || !istuple(argv[1], &n, &xs)) return __FAIL; ! for (i = 0; i < n; ++i) { ! if (isint(xs[i], &ival)) ! if (cvt_flag) ! fprintf(fp, "%d", ival); else ! fprintf(fp, "%s%d%s", str_del, ival, str_del); ! else if (isfloat(xs[i], &dval)) ! if (cvt_flag) ! fprintf(fp, "%g", dval); else ! fprintf(fp, "%s%g%s", str_del, dval, str_del); ! else if (isstr(xs[i], &sval)) { /* strings are always dquoted */ ! /* count dquotes for escape quotes */ ! for (t = sval; *t; ++t) ! if (*t == *str_del) ++qcnt; ! ! if (!(prt = malloc(strlen(sval) + qcnt + 2))) ! return __ERROR; ! ! rt = prt; ! t = sval; ! while (*t) { ! if (*t == *str_del) ! *rt++ = *t; ! *rt++ = *t++; } ! *rt = 0; ! fprintf(fp, "%s%s%s", str_del, prt, str_del); ! free(prt); ! } else ! return __FAIL; ! if (i != n - 1) ! fprintf(fp, "%s", fld_del); } ! #if defined (_WIN32) ! fprintf(fp, "\r\n"); #else ! fprintf(fp, "\n"); #endif ! ! return mkvoid; } - - /* swritecsv - - input: (field delimeter char, string delimeter char) Tuple - output: CSV formatted String - - returns: - __FAIL if arguments are not valid. - __ERROR is out of memory - */ - --- 257,370 ---- dispose(rec[n]); free(rec); ! if (exit_type == 1) { ! sprintf(errmsg, "Column %d: Unexpected end of file.", (fld_len+1)); ! return mkapp(mksym(sym(csv_error)), mkstr(strdup(errmsg))); ! } return __ERROR; } ! #define resize_str \ ! if (len > size) { \ ! if (!(tstr = realloc(str, sizeof(char)*(size <<= 1)))) { \ ! free(str); \ ! return __ERROR; \ ! } \ ! str = tstr; \ ! } \ ! t = str + mark ! #define insert_num \ ! mark = len; \ ! len += strlen(tbuff); \ ! resize_str; \ ! strncpy(t, tbuff, len - mark) ! ! /* convert tuple to csv string ! input: ! arg[0]: (Conversion flag, field delimeter char, string delimeter char) ! arg[1]: tuple to be converted ! ! output: CSV formated string ! ! exceptions: ! Returns __ERROR if no more memory is available. ! Invokes 'csv_error MSG' if a field cannot be converted. ! ! Notes: ! \r char is treated as white space except inside "" */ ! ! FUNCTION (csv, tuple_to_csvstr, argc, argv) { ! int i, n, size = 256, mark, qcnt, len = 0, cvt_f; ! char *str, *tstr, *sval, *strdl, *flddl, *p, tbuff[48], errmsg[80]; long ival; double dval; expr *xs, *ys; + register char *t; if (argc != 2 || !istuple(argv[0], &i, &ys) ! || i != 3 ! || !isbool(ys[0], &cvt_f) /* unquote flag */ ! || !isstr(ys[1], &flddl) ! || !isstr(ys[2], &strdl) || !istuple(argv[1], &n, &xs)) return __FAIL; ! ! if (!(str = (char *)malloc(size))) ! return __ERROR; ! for (i = 0; i < n; ++i) { ! if (isint(xs[i], &ival)) { ! if (cvt_f) ! sprintf(tbuff, "%d%s", ival, flddl); else ! sprintf(tbuff, "%s%d%s%s", strdl, ival, strdl, flddl); ! insert_num; ! } else if (isfloat(xs[i], &dval)) { ! if (cvt_f) ! sprintf(tbuff, "%.16g%s", dval, flddl); else ! sprintf(tbuff, "%s%.16g%s%s", strdl, dval, strdl, flddl); ! insert_num; ! } else if (isstr(xs[i], &sval)) { ! qcnt = 0; ! p = sval; ! while (*p) ! if (!strncmp(p++, strdl, 1)) ++qcnt; ! mark = len; ! len += p - sval + qcnt + 3; /* strlen + double strdls + dquotes */ ! resize_str; ! p = sval; ! *t++ = *strdl; ! while (*t++ = *p) { ! if (!strncmp(p, strdl, 1)) ! *t++ = *p; ! ++p; } ! --t; ! *t++ = *strdl; ! *t++ = *flddl; ! } else { ! sprintf(errmsg, "Field %d: Invalid conversion type.", (i+1)); ! return mkapp(mksym(sym(csv_error)), mkstr(strdup(errmsg))); ! } } ! mark = len; #if defined (_WIN32) ! len += 2; ! resize_str; ! *(t-2) = '\r'; #else ! ++len; ! resize_str; #endif ! *(t-1) = '\n'; ! *t = 0; ! str = (char *)realloc(str, len); ! return mkstr(str); } Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** csv.q 12 Jan 2008 04:30:49 -0000 1.4 --- csv.q 13 Jan 2008 17:27:14 -0000 1.5 *************** *** 21,151 **** that allow field delimiters and quote delimiters to be changed. */ ! private extern freadcsv_ ARGS; ! private extern fwritecsv_ ARGS REC; ! public freadcsv_data ARGS, freadcsv_string ARGS; ! /* _data variant converts fields to ints and floats on the fly ! _string variant makes all fields strings. ! ARGS is either a File or a tuple consisting of: ! (File, Field delimiter) or ! (File, Field delimiter, String delimiter). ! Returns a tuple of fields read. */ ! public fwritecsv_data ARGS REC, fwritecsv_string ARGS REC; ! /* _data variant converts fields to ints and floats on the fly ! _string variant writes all fields strings. ! ARGS is either a File or a tuple consisting of: ! (File, Field delimiter) or ! (File, Field delimiter, String delimiter) ! REC is a tuple of fields to be written. ! NOTE that REC may only consist of strings, ints, and floats. ! */ ! public freadfilecsv_data ARGS, freadfilecsv_string ARGS; ! /* _data variant converts fields to ints and floats on the fly ! _string variant makes all fields strings. ! ARGS is either a File or a tuple consisting of: ! (File, Field delimiter) or ! (File, Field delimiter, String delimiter). ! Returns a list where each record is a tuple of fields. */ ! public fwritefilecsv_data ARGS LIST, fwritefilecsv_string ARGS LIST; ! /* _data variant converts fields to ints and floats on the fly ! _string variant writes all fields as strings. ! ARGS is either a File or a tuple consisting of: ! (File, Field delimiter) or ! (File, Field delimiter, String delimiter). ! LIST is a list where each record is a tuple of fields. ! NOTE that REC may only consist of strings, ints, and floats. */ ! freadcsv_data F:File ! = freadcsv_ (true, F, ",", "\""); ! freadcsv_data (F:File, FieldDelim:String) ! = freadcsv_ (true, F, FieldDelim, "\""); freadcsv_data (F:File, FieldDelim:String, StrDelim:String) ! = freadcsv_ (true, F, FieldDelim, StrDelim); ! freadcsv_string F:File ! = freadcsv_ (false, F, ",", "\""); ! freadcsv_string (F:File, FieldDelim:String) ! = freadcsv_ (false, F, FieldDelim, "\""); ! freadcsv_string (F:File, FieldDelim:String, StrDelim:String) ! = freadcsv_ (false, F, FieldDelim, StrDelim); fwritecsv_data F:File Rec:Tuple ! = fwritecsv_ (true, F, ",", "\"") Rec; ! fwritecsv_data (F:File, FieldDelim:String) Rec:Tuple ! = fwritecsv_ (true, F, FieldDelim, "\"") Rec; fwritecsv_data (F:File, FieldDelim:String, StrDelim:String) Rec:Tuple ! = fwritecsv_ (true, F, FieldDelim, StrDelim) Rec; fwritecsv_string F:File Rec:Tuple ! = fwritecsv_ (false, F, ",", "\"") Rec; ! fwritecsv_string (F:File, FieldDelim:String) Rec:Tuple ! = fwritecsv_ (false, F, FieldDelim, "\"") Rec; fwritecsv_string (F:File, FieldDelim:String, StrDelim:String) Rec:Tuple ! = fwritecsv_ (false, F, FieldDelim, StrDelim) Rec; ! ! /* Only use the following functions if you KNOW the data files are small */ ! ! freadfilecsv_data F:File ! = [] if feof F; ! = [freadcsv_ (true, F, ",", "\"") ! | freadfilecsv_data F]; ! freadfilecsv_data (F:File, FieldDelim:String) ! = [] if feof F; ! = [freadcsv_ (true, F, FieldDelim, "\"") ! | freadfilecsv_data (F, FieldDelim)]; ! freadfilecsv_data (F:File, FieldDelim:String, StrDelim:String) ! = [] if feof F; ! = [freadcsv_ (true, F, FieldDelim, StrDelim) ! | freadfilecsv_data (F, FieldDelim, StrDelim)]; ! ! freadfilecsv_string F:File ! = [] if feof F; ! = [freadcsv_ (false, F, ",", "\"") ! | freadfilecsv_string F]; ! freadfilecsv_string (F:File, FieldDelim:String) ! = [] if feof F; ! = [freadcsv_ (false, F, FieldDelim, "\"") ! | freadfilecsv_string (F, FieldDelim)]; ! freadfilecsv_string (F:File, FieldDelim:String, StrDelim:String) ! = [] if feof F; ! = [freadcsv_ (false, F, FieldDelim, StrDelim) | ! freadfilecsv_string (F, FieldDelim, StrDelim)]; ! fwritefilecsv_data F:File L:List ! = do (fwritecsv_ (true, F, ",", "\"")) L; ! fwritefilecsv_data (F:File, FieldDelim:String) L:List ! = do (fwritecsv_ (true, F, FieldDelim, "\"")) L; ! fwritefilecsv_data (F:File, FieldDelim:String, StrDelim:String) L:List ! = do (fwritecsv_ (true, F, FieldDelim, StrDelim)) L; ! fwritefilecsv_string F:File L:List ! = do (fwritecsv_ (false, F, ",", "\"")) L; ! fwritefilecsv_string (F:File, FieldDelim:String) L:List ! = do (fwritecsv_ (false, F, FieldDelim, "\"")) L; ! fwritefilecsv_string (F:File, FieldDelim:String, StrDelim:String) L:List ! = do (fwritecsv_ (false, F, FieldDelim, StrDelim)) L; ! /* Primary interface functions. These are defined to be the _data variants by ! default, but you can change this using appropriate definitions in your ! program. */ ! public freadcsv ARGS, fwritecsv ARGS REC; ! /* freadcsv ARGS = freadcsv_data ARGS ! fwritecsv ARGS = fwritecsv_data ARGS REC */ ! public freadfilecsv ARGS, fwritefilecsv ARGS REC; ! /* freadfilecsv ARGS = freadfilecsv_data ARGS ! fwritefilecsv ARGS REC = fwritefilecsv_data ARGS REC */ ! @-0x80000000 ! freadcsv = freadcsv_data; ! freadfilecsv = freadfilecsv_data; ! fwritecsv = fwritecsv_data; ! fwritefilecsv = fwritefilecsv_data; ! @0 \ No newline at end of file --- 21,117 ---- that allow field delimiters and quote delimiters to be changed. */ ! public extern fread_csvstr FILE STRDELIM; ! /* Read a CSV record from a file (including embedded new lines). ! FILE: file to be read from ! STRDELIM: string delimiter used in the CSV format ! NOTE: fread_csvstr does not take into account badly formated records. ! csvstr_to_tuple is necessary for error checking. */ ! public extern tuple_to_csvstr ARGS REC; ! /* Convert a tuple (record) to CSV string ! ARGS: tuple (auto conversion flag, field delimiter, string delimiter) ! REC: tuple of fields to be converted to CSV format ! NOTES ! (1) REC must contain ONLY strings, integers, and floating point numbers. ! If a field is some other type, the 'csv_error MSG' rule is invoked. ! (2) When the auto conversion flag is false, ALL fields are strings. */ ! public extern csvstr_to_tuple ARGS STR; ! /* Convert CSV string to a tuple (record). ! ARGS: tuple (auto conversion flag, field delimiter, string delimiter) ! STR: tuple of fields to be converted to CSV format ! ! NOTES ! (1) A properly formated CSV string MUST end with a '\n' ! (2) When the auto conversion flag is false, All fields are strings. ! (3) The 'csv_error MSG' rule is invoked on improperly formated strings. */ ! public csv_error MSG; ! /* User may define csv_error for custom error handling. */ ! ! public freadcsv_data ARGS; ! /* Read one CSV record from the file with number conversion. */ ! ! freadcsv_data F:File ! = csvstr_to_tuple (true, ",", "\"") (fread_csvstr F "\""); freadcsv_data (F:File, FieldDelim:String, StrDelim:String) ! = csvstr_to_tuple (true, FieldDelim, StrDelim) (fread_csvstr F StrDelim); ! public freadcsv_string ARGS; ! /* Read one CSV record from the file without number conversion. */ ! ! freadcsv_string F:File ! = csvstr_to_tuple (false, "," "\"") (fread_csvstr F "\""); ! freadcsv_string_data (F:File, FieldDelim:String, StrDelim:String) ! = csvstr_to_tuple (false, "," "\"") (fread_csvstr F StrDelim); ! ! public fwritecsv_data FILE REC; ! /* Write one CSV record to a file with number conversion. */ fwritecsv_data F:File Rec:Tuple ! = fwrites F (tuple_to_csvstr (true, ",", "\"") Rec); fwritecsv_data (F:File, FieldDelim:String, StrDelim:String) Rec:Tuple ! = fwrites F (tuple_to_csvstr (true, FieldDelim, StrDelim) Rec); ! ! public fwritecsv_string FILE REC; ! /* Write one CSV record to a file without number conversion. */ fwritecsv_string F:File Rec:Tuple ! = fwrites F (tuple_to_csvstr (false, ",", "\"") Rec); fwritecsv_string (F:File, FieldDelim:String, StrDelim:String) Rec:Tuple ! = fwrites F (tuple_to_csvstr (false, FieldDelim, StrDelim) Rec); ! public freadcsvfile_data ARGS, freadcsvfile_string ARGS; ! /* Read an entire file of records into a list of tuples. */ ! freadcsvfile_data F:File ! = [] if feof F; ! = [freadscsv_data F | freadcsvfile_data F]; ! freadcsvfile_data (F:File, FieldDelim:String, StrDelim:String) ! = [] if feof F; ! = [freadscsv_data (F, FieldDelim, StrDelim) | freadcsvfile_data F]; ! freadcsvfile_string F:File ! = [] if feof F; ! = [freadscsv_string F | freadcsvfile_dara F]; ! freadcsvfile_string (F:File, FieldDelim:String, StrDelim:String) ! = [] if feof F; ! = [freadscsv_string (F, FieldDelim, StrDelim) | freadcsvfile_string F]; ! public fwritecsvfile_data FILE LIST, fwritefile_string ARGS; ! /* Write a list of tuples to a CSV formated file. */ ! fwritecsvfile_data F:File L:List ! = do (fwritecsv_data F) L; ! fwritecsvfile_data (F:File, FieldDelim:String, StrDelim:String) L:List ! = do (fwritecsv_data (F, FieldDelim, StrDelim)) L; ! fwritecsvfile_string F:File L:List ! = do (fwritecsv_string F) L; ! fwritecsvfile_string (F:File, FieldDelim:String, StrDelim:String) L:List ! = do (fwritecsv_string (F, FieldDelim, StrDelim)) L; \ No newline at end of file |
From: RER <ed...@us...> - 2008-01-13 17:27:20
|
Update of /cvsroot/q-lang/q-csv/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31912/examples Modified Files: read-sample1.csv read-sample2.csv read-sample4.csv readsamples.q writesamples.q Log Message: updated README, read samples, write samples, csv.c, and csv.q Index: writesamples.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/examples/writesamples.q,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** writesamples.q 10 Jan 2008 22:54:02 -0000 1.2 --- writesamples.q 13 Jan 2008 17:27:14 -0000 1.3 *************** *** 2,6 **** To run: ! At the command line> q writesamples.q At the prompt ==> main Using your favorite editor open the write samples to see what was wrought. --- 2,6 ---- To run: ! At the command line> Q writesamples.q At the prompt ==> main Using your favorite editor open the write samples to see what was wrought. *************** *** 17,21 **** Note that certain fields are not quoted. */ writefile F [] = (); ! writefile F [L|Ls] = [fwritecsv F L | writefile F Ls]; /* Illustration of writecsv_string --- 17,21 ---- Note that certain fields are not quoted. */ writefile F [] = (); ! writefile F [L|Ls] = [fwritecsv_data F L | writefile F Ls]; /* Illustration of writecsv_string *************** *** 26,30 **** /* Illustration of fwritecsv with tab delimeter */ writefile_tab F [] = (); ! writefile_tab F [L|Ls] = [fwritecsv (F, "\t") L | writefile_tab F Ls]; /* Illustration of fwritecsv with tab and quote delimeters */ --- 26,30 ---- /* Illustration of fwritecsv with tab delimeter */ writefile_tab F [] = (); ! writefile_tab F [L|Ls] = [fwritecsv_data (F, "\t", "\"") L | writefile_tab F Ls]; /* Illustration of fwritecsv with tab and quote delimeters */ *************** *** 45,61 **** ("a, b", "", 0, 0.0, "00")]; ! main = writes "Writing 'write-sample1.csv': (standard CSV)\n" || writefile (fopen "write-sample1.csv" "w") Sample1 ! || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample2.csv': (standard CSV, quoted)\n" || writefile_string (fopen "write-sample2.csv" "w") Sample1 ! || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample3.csv': (tab delimited)\n" || writefile_tab (fopen "write-sample3.csv" "w") Sample2 ! || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample4.csv': (tab delimited, single quoted)\n" || writefile_tab_quote (fopen "write-sample4.csv" "w") Sample3 ! || writes "\ndone.\n\n-----\n"; ! ! main2 = fwritefilecsv_data (F, "\t", "'") Sample3 ! where F = fopen "write-sample4.csv" "w"; \ No newline at end of file --- 45,58 ---- ("a, b", "", 0, 0.0, "00")]; ! main = writes "Writing 'write-sample1.csv: (standard CSV)" || writefile (fopen "write-sample1.csv" "w") Sample1 ! || writes "\ndone.\n\n-----" ! || writes "Writing 'write-sample2.csv: (standard CSV, quoted)" || writefile_string (fopen "write-sample2.csv" "w") Sample1 ! || writes "\ndone.\n\n-----" ! || writes "Writing 'write-sample3.csv: (tab delimited)" || writefile_tab (fopen "write-sample3.csv" "w") Sample2 ! || writes "\ndone.\n\n-----" ! || writes "Writing 'write-sample4.csv: (tab delimited, single quoted)" || writefile_tab_quote (fopen "write-sample4.csv" "w") Sample3 ! || writes "\ndone.\n\n-----"; \ No newline at end of file Index: read-sample2.csv =================================================================== RCS file: /cvsroot/q-lang/q-csv/examples/read-sample2.csv,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** read-sample2.csv 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- read-sample2.csv 13 Jan 2008 17:27:14 -0000 1.2 *************** *** 1,4 **** ! 4 "0004" ! "this has an embedded tab" 3.2 "0000" ! "embedded ""quotes""" "-10", 0 " " ! 2.3e-4 54-23 \ No newline at end of file --- 1,4 ---- ! 4 "0004" ! "this has an embedded tab" 3.2 "0000" ! " this""quotes""" "-10, 0" " " ! 2.3e-4 54-23 \ No newline at end of file Index: readsamples.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/examples/readsamples.q,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** readsamples.q 10 Jan 2008 22:54:02 -0000 1.2 --- readsamples.q 13 Jan 2008 17:27:14 -0000 1.3 *************** *** 2,6 **** To run: ! at the command line> q readsamples.q at the prompt ==> main */ --- 2,6 ---- To run: ! at the command line> Q readsamples.q at the prompt ==> main */ *************** *** 17,21 **** Note that integer and float fields are automatically converted. */ readfile F = [] if feof F; ! = [freadcsv F | readfile F]; /* Illustration of freadcsv_string --- 17,21 ---- Note that integer and float fields are automatically converted. */ readfile F = [] if feof F; ! = [freadcsv_data F | readfile F]; /* Illustration of freadcsv_string *************** *** 26,47 **** /* Illustration of freadcsv with tab delimeter */ readfile_tab F = [] if feof F; ! = [freadcsv (F, "\t") | readfile_tab F]; /* Illustration of freadcsv with tab and quote delimeters */ readfile_tab_quote F = [] if feof F; ! = [freadcsv (F, "\t", ",") | readfile_tab_quote F]; ! main = writes "Reading 'read-sample1.csv': (standard CSV)\n" || write (readfile (fopen "read-sample1.csv" "r")) ! || writes "\n\n-----\n" ! || writes "Reading 'read-sample1.csv': (standard CSV, no convertions)\n" || write (readfile_string (fopen "read-sample1.csv" "r")) ! || writes "\n\n-----\n" ! || writes "Reading 'read-sample2.csv': (tab delimited)\n" || write (readfile_tab (fopen "read-sample2.csv" "r")) ! || writes "\n\n-----\n" ! || writes "Reading 'read-sample3.csv': (tab delimited, single quoted)\n" || write (readfile_tab (fopen "read-sample3.csv" "r")) ! || writes "\n\n-----\n" ! || writes "Reading 'read-sample4.csv': (Malformed)\n" || write (readfile (fopen "read-sample4.csv" "r")); \ No newline at end of file --- 26,47 ---- /* Illustration of freadcsv with tab delimeter */ readfile_tab F = [] if feof F; ! = [freadcsv_data (F, "\t", "\"") | readfile_tab F]; /* Illustration of freadcsv with tab and quote delimeters */ readfile_tab_quote F = [] if feof F; ! = [freadcsv_data (F, "\t", ",") | readfile_tab_quote F]; ! main = writes "Reading 'read-sample1.csv: (standard CSV)" || write (readfile (fopen "read-sample1.csv" "r")) ! || writes "\n\n-----" ! || writes "Reading 'read-sample1.csv: (standard CSV, no convertions)" || write (readfile_string (fopen "read-sample1.csv" "r")) ! || writes "\n\n-----" ! || writes "Reading 'read-sample2.csv: (tab delimited)" || write (readfile_tab (fopen "read-sample2.csv" "r")) ! || writes "\n\n-----" ! || writes "Reading 'read-sample3.csv: (tab delimited, single quoted)" || write (readfile_tab (fopen "read-sample3.csv" "r")) ! || writes "\n\n-----" ! || writes "Reading 'read-sample4.csv: (Malformed)\n" || write (readfile (fopen "read-sample4.csv" "r")); \ No newline at end of file Index: read-sample1.csv =================================================================== RCS file: /cvsroot/q-lang/q-csv/examples/read-sample1.csv,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** read-sample1.csv 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- read-sample1.csv 13 Jan 2008 17:27:14 -0000 1.2 *************** *** 1,3 **** ! ,,4,"0004" "this, has an embedded ," ,, 3.2, "0000" "embedded ""quotes""", "-10", 0 , " " --- 1,6 ---- ! ,,4,"0004" ! "embedded ! new ! lines", "4", 0.1, "----" "this, has an embedded ," ,, 3.2, "0000" "embedded ""quotes""", "-10", 0 , " " Index: read-sample4.csv =================================================================== RCS file: /cvsroot/q-lang/q-csv/examples/read-sample4.csv,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** read-sample4.csv 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- read-sample4.csv 13 Jan 2008 17:27:14 -0000 1.2 *************** *** 1,4 **** ! ,,4,"0004" "this, has an embedded ," ,, 3.2, "0000" embedded ""quotes"", "-10", 0 , " " ! , , , 2.3e-4 , "54-23 \ No newline at end of file --- 1,4 ---- ! ,,4,"0004" "this, has an embedded ," ,, 3.2, "0000" embedded ""quotes"", "-10", 0 , " " ! ," , , 2.3e-4 , "54-23 \ No newline at end of file |
From: RER <ed...@us...> - 2008-01-12 13:37:57
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32728 Modified Files: csv.c Log Message: testing cvs Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** csv.c 10 Jan 2008 22:59:35 -0000 1.2 --- csv.c 12 Jan 2008 13:37:49 -0000 1.3 *************** *** 16,20 **** ! Written by Eddie Rucker 3-8 Jan, 2008 */ #include <stdio.h> --- 16,22 ---- ! Written by Eddie Rucker 3-12 Jan, 2008 */ ! ! /* Test to see if cvs is working */ #include <stdio.h> |
From: Albert G. - T. u. <ag...@us...> - 2008-01-12 04:30:54
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22288 Modified Files: csv.q Log Message: remove extra trailing whitespace Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** csv.q 10 Jan 2008 23:40:16 -0000 1.3 --- csv.q 12 Jan 2008 04:30:49 -0000 1.4 *************** *** 17,22 **** /* The CSV library provides an interface to read and write comma separated ! value files. The reading and writing functions abide by RFC 4180 ! (http://www.ietf.org/rfc/rfc4180.txt) except for additional parameters that allow field delimiters and quote delimiters to be changed. */ --- 17,22 ---- /* The CSV library provides an interface to read and write comma separated ! value files. The reading and writing functions abide by RFC 4180 ! (http://www.ietf.org/rfc/rfc4180.txt) except for additional parameters that allow field delimiters and quote delimiters to be changed. */ *************** *** 64,68 **** freadcsv_data F:File = freadcsv_ (true, F, ",", "\""); ! freadcsv_data (F:File, FieldDelim:String) = freadcsv_ (true, F, FieldDelim, "\""); freadcsv_data (F:File, FieldDelim:String, StrDelim:String) --- 64,68 ---- freadcsv_data F:File = freadcsv_ (true, F, ",", "\""); ! freadcsv_data (F:File, FieldDelim:String) = freadcsv_ (true, F, FieldDelim, "\""); freadcsv_data (F:File, FieldDelim:String, StrDelim:String) *************** *** 71,80 **** freadcsv_string F:File = freadcsv_ (false, F, ",", "\""); ! freadcsv_string (F:File, FieldDelim:String) = freadcsv_ (false, F, FieldDelim, "\""); freadcsv_string (F:File, FieldDelim:String, StrDelim:String) = freadcsv_ (false, F, FieldDelim, StrDelim); ! fwritecsv_data F:File Rec:Tuple = fwritecsv_ (true, F, ",", "\"") Rec; fwritecsv_data (F:File, FieldDelim:String) Rec:Tuple --- 71,80 ---- freadcsv_string F:File = freadcsv_ (false, F, ",", "\""); ! freadcsv_string (F:File, FieldDelim:String) = freadcsv_ (false, F, FieldDelim, "\""); freadcsv_string (F:File, FieldDelim:String, StrDelim:String) = freadcsv_ (false, F, FieldDelim, StrDelim); ! fwritecsv_data F:File Rec:Tuple = fwritecsv_ (true, F, ",", "\"") Rec; fwritecsv_data (F:File, FieldDelim:String) Rec:Tuple *************** *** 83,87 **** = fwritecsv_ (true, F, FieldDelim, StrDelim) Rec; ! fwritecsv_string F:File Rec:Tuple = fwritecsv_ (false, F, ",", "\"") Rec; fwritecsv_string (F:File, FieldDelim:String) Rec:Tuple --- 83,87 ---- = fwritecsv_ (true, F, FieldDelim, StrDelim) Rec; ! fwritecsv_string F:File Rec:Tuple = fwritecsv_ (false, F, ",", "\"") Rec; fwritecsv_string (F:File, FieldDelim:String) Rec:Tuple *************** *** 94,119 **** freadfilecsv_data F:File = [] if feof F; ! = [freadcsv_ (true, F, ",", "\"") | freadfilecsv_data F]; freadfilecsv_data (F:File, FieldDelim:String) = [] if feof F; ! = [freadcsv_ (true, F, FieldDelim, "\"") | freadfilecsv_data (F, FieldDelim)]; ! freadfilecsv_data (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadcsv_ (true, F, FieldDelim, StrDelim) | freadfilecsv_data (F, FieldDelim, StrDelim)]; freadfilecsv_string F:File = [] if feof F; ! = [freadcsv_ (false, F, ",", "\"") | freadfilecsv_string F]; freadfilecsv_string (F:File, FieldDelim:String) = [] if feof F; ! = [freadcsv_ (false, F, FieldDelim, "\"") | freadfilecsv_string (F, FieldDelim)]; ! freadfilecsv_string (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadcsv_ (false, F, FieldDelim, StrDelim) | freadfilecsv_string (F, FieldDelim, StrDelim)]; --- 94,119 ---- freadfilecsv_data F:File = [] if feof F; ! = [freadcsv_ (true, F, ",", "\"") | freadfilecsv_data F]; freadfilecsv_data (F:File, FieldDelim:String) = [] if feof F; ! = [freadcsv_ (true, F, FieldDelim, "\"") | freadfilecsv_data (F, FieldDelim)]; ! freadfilecsv_data (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadcsv_ (true, F, FieldDelim, StrDelim) | freadfilecsv_data (F, FieldDelim, StrDelim)]; freadfilecsv_string F:File = [] if feof F; ! = [freadcsv_ (false, F, ",", "\"") | freadfilecsv_string F]; freadfilecsv_string (F:File, FieldDelim:String) = [] if feof F; ! = [freadcsv_ (false, F, FieldDelim, "\"") | freadfilecsv_string (F, FieldDelim)]; ! freadfilecsv_string (F:File, FieldDelim:String, StrDelim:String) = [] if feof F; ! = [freadcsv_ (false, F, FieldDelim, StrDelim) | freadfilecsv_string (F, FieldDelim, StrDelim)]; *************** *** 137,141 **** public freadcsv ARGS, fwritecsv ARGS REC; ! /* freadcsv ARGS = freadcsv_data ARGS fwritecsv ARGS = fwritecsv_data ARGS REC */ --- 137,141 ---- public freadcsv ARGS, fwritecsv ARGS REC; ! /* freadcsv ARGS = freadcsv_data ARGS fwritecsv ARGS = fwritecsv_data ARGS REC */ |
From: Albert G. <ag...@us...> - 2008-01-10 23:41:24
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv509 Modified Files: README Log Message: elaborate on different kinds of available interface functions Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** README 10 Jan 2008 23:14:46 -0000 1.5 --- README 10 Jan 2008 23:41:21 -0000 1.6 *************** *** 8,12 **** that allow field delimiters and quote delimiters to be changed. ! Two variants of reading and writing are available: - freadcsv_data converts non-quoted numeric fields to integer or double values --- 8,29 ---- that allow field delimiters and quote delimiters to be changed. ! INSTALLATION ! ! This module is (or will soon be) included in the binary "all in one" packages ! available from the Q website. Use these if you can. To install from the ! sources, run 'make' to compile the module and 'make install' (as root) to ! install it under the default prefix (/usr/local). If your Q installation lives ! elsewhere (e.g., under /usr), you can specify the installation prefix as ! follows: 'make prefix=/usr install'. (It is recommended to install the module ! under the same prefix as the Q interpreter so that the interpreter can find ! the module. Otherwise you might have to modify your QPATH accordingly.) ! ! USAGE ! ! Data records are represented as tuples of strings and numeric data. Two ! variants of reading and writing are available. Basically, the functions whose ! names end in _data will convert numeric (integer and floating point) values ! automatically, while the _string variants will treat them as ordinary (string) ! data. More precisely: - freadcsv_data converts non-quoted numeric fields to integer or double values *************** *** 19,34 **** fwritecsv_string writes all values as quoted fields. ! INSTALLATION ! This module is (or will soon be) included in the binary "all in one" packages ! available from the Q website. Use these if you can. ! To install from the sources, run 'make' to compile the module and 'make ! install' (as root) to install it under the default prefix (/usr/local). If ! your Q installation lives elsewhere (e.g., under /usr), you can specify the ! installation prefix as follows: 'make prefix=/usr install'. (It is recommended ! to install the module under the same prefix as the Q interpreter so that the ! interpreter finds the module. Otherwise you might have to modify your QPATH ! accordingly.) NOTES --- 36,51 ---- fwritecsv_string writes all values as quoted fields. ! The primary interface functions freadcsv and fwritecsv are defined to be ! equivalent to the _data variants by default. If necessary, you can change this ! by adding appropriate definitions to your program, i.e.: ! freadcsv = freadcsv_string; ! fwritecsv = fwritecsv_string; ! The routines described above read/write one record at a time. Additional ! functions (freadfilecsv and fwritefilecsv, again with corresponding _data and ! _string variants) are provided to convert between entire CSV files and lists ! of tuples. Note that these require that the entire data fits into RAM and will ! thus be inefficient for huge datasets. NOTES |
From: Albert G. <ag...@us...> - 2008-01-10 23:40:20
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32545 Modified Files: csv.q Log Message: add comment about primary interface functions Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** csv.q 10 Jan 2008 22:59:35 -0000 1.2 --- csv.q 10 Jan 2008 23:40:16 -0000 1.3 *************** *** 132,135 **** --- 132,139 ---- = do (fwritecsv_ (false, F, FieldDelim, StrDelim)) L; + /* Primary interface functions. These are defined to be the _data variants by + default, but you can change this using appropriate definitions in your + program. */ + public freadcsv ARGS, fwritecsv ARGS REC; /* freadcsv ARGS = freadcsv_data ARGS |
From: Albert G. <ag...@us...> - 2008-01-10 23:14:50
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21301 Modified Files: README Log Message: cosmetic changes Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README 10 Jan 2008 23:13:29 -0000 1.4 --- README 10 Jan 2008 23:14:46 -0000 1.5 *************** *** 34,39 **** NOTES ! - The calling rule is returned when reading records that do not abide by the ! RFC 4180 rules. - MS Excel files should be read using _string variants as Excel does not quote --- 34,39 ---- NOTES ! - The read functions fail when reading records that do not abide by the RFC ! 4180 rules. - MS Excel files should be read using _string variants as Excel does not quote |
From: Albert G. <ag...@us...> - 2008-01-10 23:13:34
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20827 Modified Files: README Log Message: add install instructions Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README 10 Jan 2008 22:59:35 -0000 1.3 --- README 10 Jan 2008 23:13:29 -0000 1.4 *************** *** 19,22 **** --- 19,35 ---- fwritecsv_string writes all values as quoted fields. + INSTALLATION + + This module is (or will soon be) included in the binary "all in one" packages + available from the Q website. Use these if you can. + + To install from the sources, run 'make' to compile the module and 'make + install' (as root) to install it under the default prefix (/usr/local). If + your Q installation lives elsewhere (e.g., under /usr), you can specify the + installation prefix as follows: 'make prefix=/usr install'. (It is recommended + to install the module under the same prefix as the Q interpreter so that the + interpreter finds the module. Otherwise you might have to modify your QPATH + accordingly.) + NOTES |
From: Albert G. <ag...@us...> - 2008-01-10 22:59:47
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14596 Modified Files: README csv.c csv.q Log Message: fix broken links Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README 10 Jan 2008 22:54:02 -0000 1.2 --- README 10 Jan 2008 22:59:35 -0000 1.3 *************** *** 5,9 **** The CSV library provides an interface to read and write comma separated value files. The reading and writing functions abide by RFC 4180 ! (http://tools.ietf.rg/html/rfc4180.txt) except for additional parameters that allow field delimiters and quote delimiters to be changed. --- 5,9 ---- The CSV library provides an interface to read and write comma separated value files. The reading and writing functions abide by RFC 4180 ! (http://www.ietf.org/rfc/rfc4180.txt) except for additional parameters that allow field delimiters and quote delimiters to be changed. Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** csv.c 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- csv.c 10 Jan 2008 22:59:35 -0000 1.2 *************** *** 1,3 **** ! /* CSV according to RFC 4180 (http://tools.ietf.rg/html/rfc4180) This is free software; you can redistribute it and/or --- 1,3 ---- ! /* CSV according to RFC 4180 (http://www.ietf.org/rfc/rfc4180.txt) This is free software; you can redistribute it and/or Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** csv.q 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- csv.q 10 Jan 2008 22:59:35 -0000 1.2 *************** *** 18,22 **** /* The CSV library provides an interface to read and write comma separated value files. The reading and writing functions abide by RFC 4180 ! (http://tools.ietf.rg/html/rfc4180.txt) except for additional parameters that allow field delimiters and quote delimiters to be changed. */ --- 18,22 ---- /* The CSV library provides an interface to read and write comma separated value files. The reading and writing functions abide by RFC 4180 ! (http://www.ietf.org/rfc/rfc4180.txt) except for additional parameters that allow field delimiters and quote delimiters to be changed. */ |
From: Albert G. <ag...@us...> - 2008-01-10 22:54:06
|
Update of /cvsroot/q-lang/q-csv/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12175/examples Modified Files: readsamples.q writesamples.q Log Message: fix typos Index: writesamples.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/examples/writesamples.q,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** writesamples.q 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- writesamples.q 10 Jan 2008 22:54:02 -0000 1.2 *************** *** 2,6 **** To run: ! At the command line> Q writesamples.q At the prompt ==> main Using your favorite editor open the write samples to see what was wrought. --- 2,6 ---- To run: ! At the command line> q writesamples.q At the prompt ==> main Using your favorite editor open the write samples to see what was wrought. *************** *** 45,58 **** ("a, b", "", 0, 0.0, "00")]; ! main = writes "Writing 'write-sample1.csv: (standard CSV)\n" || writefile (fopen "write-sample1.csv" "w") Sample1 || writes "\ndone.\n\n-----\n" ! || write "Writing 'write-sample2.csv: (standard CSV, quoted)\n" || writefile_string (fopen "write-sample2.csv" "w") Sample1 || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample3.csv: (tab delimited)\n" || writefile_tab (fopen "write-sample3.csv" "w") Sample2 || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample4.csv: (tab delimited, single quoted)\n" || writefile_tab_quote (fopen "write-sample4.csv" "w") Sample3 || writes "\ndone.\n\n-----\n"; --- 45,58 ---- ("a, b", "", 0, 0.0, "00")]; ! main = writes "Writing 'write-sample1.csv': (standard CSV)\n" || writefile (fopen "write-sample1.csv" "w") Sample1 || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample2.csv': (standard CSV, quoted)\n" || writefile_string (fopen "write-sample2.csv" "w") Sample1 || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample3.csv': (tab delimited)\n" || writefile_tab (fopen "write-sample3.csv" "w") Sample2 || writes "\ndone.\n\n-----\n" ! || writes "Writing 'write-sample4.csv': (tab delimited, single quoted)\n" || writefile_tab_quote (fopen "write-sample4.csv" "w") Sample3 || writes "\ndone.\n\n-----\n"; Index: readsamples.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/examples/readsamples.q,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** readsamples.q 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- readsamples.q 10 Jan 2008 22:54:02 -0000 1.2 *************** *** 2,6 **** To run: ! at the command line> Q readsamples.q at the prompt ==> main */ --- 2,6 ---- To run: ! at the command line> q readsamples.q at the prompt ==> main */ *************** *** 32,47 **** = [freadcsv (F, "\t", ",") | readfile_tab_quote F]; ! main = writes "Reading 'read-sample1.csv: (standard CSV)\n" || write (readfile (fopen "read-sample1.csv" "r")) || writes "\n\n-----\n" ! || write "Reading 'read-sample1.csv: (standard CSV, no convertions)\n" || write (readfile_string (fopen "read-sample1.csv" "r")) || writes "\n\n-----\n" ! || writes "Reading 'read-sample2.csv: (tab delimited)\n" || write (readfile_tab (fopen "read-sample2.csv" "r")) || writes "\n\n-----\n" ! || writes "Reading 'read-sample3.csv: (tab delimited, single quoted)\n" || write (readfile_tab (fopen "read-sample3.csv" "r")) || writes "\n\n-----\n" ! || writes "Reading 'read-sample4.csv: (Malformed)\n" || write (readfile (fopen "read-sample4.csv" "r")); \ No newline at end of file --- 32,47 ---- = [freadcsv (F, "\t", ",") | readfile_tab_quote F]; ! main = writes "Reading 'read-sample1.csv': (standard CSV)\n" || write (readfile (fopen "read-sample1.csv" "r")) || writes "\n\n-----\n" ! || writes "Reading 'read-sample1.csv': (standard CSV, no convertions)\n" || write (readfile_string (fopen "read-sample1.csv" "r")) || writes "\n\n-----\n" ! || writes "Reading 'read-sample2.csv': (tab delimited)\n" || write (readfile_tab (fopen "read-sample2.csv" "r")) || writes "\n\n-----\n" ! || writes "Reading 'read-sample3.csv': (tab delimited, single quoted)\n" || write (readfile_tab (fopen "read-sample3.csv" "r")) || writes "\n\n-----\n" ! || writes "Reading 'read-sample4.csv': (Malformed)\n" || write (readfile (fopen "read-sample4.csv" "r")); \ No newline at end of file |
From: Albert G. <ag...@us...> - 2008-01-10 22:54:06
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12175 Modified Files: README Log Message: fix typos Index: README =================================================================== RCS file: /cvsroot/q-lang/q-csv/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** README 10 Jan 2008 22:41:21 -0000 1.1.1.1 --- README 10 Jan 2008 22:54:02 -0000 1.2 *************** *** 25,29 **** - MS Excel files should be read using _string variants as Excel does not quote ! values such as 0004. These types of values will be converted integers. and the leading significant 0s will be lost. Significant leading or trailing space may likewise be lost without using the _string variant. --- 25,29 ---- - MS Excel files should be read using _string variants as Excel does not quote ! values such as 0004. These types of values will be converted to integers and the leading significant 0s will be lost. Significant leading or trailing space may likewise be lost without using the _string variant. *************** *** 38,42 **** EXAMPLES ! Examples are provided in the examples subdirectory. See "readsamples.q" for reading csv files and "writesamples.q" for writing. Jan 10 2008 --- 38,43 ---- EXAMPLES ! Examples are provided in the examples subdirectory. See "readsamples.q" for ! reading csv files and "writesamples.q" for writing. Jan 10 2008 |
From: Albert G. <ag...@us...> - 2008-01-08 10:54:05
|
Update of /cvsroot/q-lang/qt-q/src In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13512/src Modified Files: smokeqt.i Log Message: typo fix Index: smokeqt.i =================================================================== RCS file: /cvsroot/q-lang/qt-q/src/smokeqt.i,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** smokeqt.i 8 Dec 2007 08:51:25 -0000 1.30 --- smokeqt.i 8 Jan 2008 10:53:59 -0000 1.31 *************** *** 4625,4629 **** %fini %{ qtobj_map.clear(); ! if (!nilobj) freeref(nilobj); %} --- 4625,4629 ---- %fini %{ qtobj_map.clear(); ! if (nilobj) freeref(nilobj); %} |
From: Albert G. <ag...@us...> - 2007-12-17 22:09:39
|
Update of /cvsroot/q-lang/qcalc/doc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23503 Modified Files: version.texi Log Message: update documentation Index: version.texi =================================================================== RCS file: /cvsroot/q-lang/qcalc/doc/version.texi,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version.texi 4 Nov 2007 20:24:20 -0000 1.1 --- version.texi 17 Dec 2007 22:09:34 -0000 1.2 *************** *** 1,4 **** @set UPDATED 20 October 2007 @set UPDATED-MONTH October 2007 ! @set EDITION 7.8 ! @set VERSION 7.8 --- 1,4 ---- @set UPDATED 20 October 2007 @set UPDATED-MONTH October 2007 ! @set EDITION 7.10 ! @set VERSION 7.10 |
From: Albert G. <ag...@us...> - 2007-12-17 22:05:51
|
Update of /cvsroot/q-lang/q In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22206 Modified Files: ChangeLog NEWS README configure.in Log Message: bump version number, update docs Index: README =================================================================== RCS file: /cvsroot/q-lang/q/README,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** README 7 Dec 2007 23:06:16 -0000 1.62 --- README 17 Dec 2007 22:05:41 -0000 1.63 *************** *** 1,4 **** ! Q eQuational Programming System Version 7.9 Copyright (c) 1991-2007 by Albert Graef <ag...@mu..., Dr....@t-...> --- 1,4 ---- ! Q eQuational Programming System Version 7.10 Copyright (c) 1991-2007 by Albert Graef <ag...@mu..., Dr....@t-...> Index: NEWS =================================================================== RCS file: /cvsroot/q-lang/q/NEWS,v retrieving revision 1.133 retrieving revision 1.134 diff -C2 -d -r1.133 -r1.134 *** NEWS 7 Dec 2007 23:06:56 -0000 1.133 --- NEWS 17 Dec 2007 22:05:41 -0000 1.134 *************** *** 3,6 **** --- 3,14 ---- ======= + * 7.10 17 December 2007 + + Another bugfix release which fixes some bugs in the clib module, see the + ChangeLog for details. + + + ------------------------------------------------------------------------------ + * 7.9 8 December 2007 Index: ChangeLog =================================================================== RCS file: /cvsroot/q-lang/q/ChangeLog,v retrieving revision 1.311 retrieving revision 1.312 diff -C2 -d -r1.311 -r1.312 *** ChangeLog 16 Dec 2007 20:35:58 -0000 1.311 --- ChangeLog 17 Dec 2007 22:05:41 -0000 1.312 *************** *** 1,4 **** --- 1,6 ---- 2007-12-16 Albert Graef <Dr....@t-...> + + Release 7.10 + * modules/clib/clib.c, modules/clib/system.c, modules/clib/clib.q, modules/clib/system.q: moved SIG* and SCHED* constants from Index: configure.in =================================================================== RCS file: /cvsroot/q-lang/q/configure.in,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** configure.in 7 Dec 2007 23:08:00 -0000 1.56 --- configure.in 17 Dec 2007 22:05:41 -0000 1.57 *************** *** 5,9 **** AC_INIT(src/q.c) AM_CONFIG_HEADER(config.h) ! AM_INIT_AUTOMAKE(q, 7.9) dnl AM_MAINTAINER_MODE --- 5,9 ---- AC_INIT(src/q.c) AM_CONFIG_HEADER(config.h) ! AM_INIT_AUTOMAKE(q, 7.10) dnl AM_MAINTAINER_MODE |