[q-lang-cvs] q-csv csv.c,1.19,1.20 csv.q,1.17,1.18
Brought to you by:
agraef
From: RER <ed...@us...> - 2008-03-06 16:19:54
|
Update of /cvsroot/q-lang/q-csv In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1836 Modified Files: csv.c csv.q Log Message: Bugfixes and lineterminator defaults Index: csv.c =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** csv.c 29 Feb 2008 21:30:20 -0000 1.19 --- csv.c 6 Mar 2008 16:19:08 -0000 1.20 *************** *** 208,211 **** --- 208,212 ---- st = 1; } else if (!*s || *s == EOF || !strncmp(s, lineterm, n_lineterm)) { + putrec(CSV_QUOTE_ALL); st = 10; } else if (isspace(*s) && skipspace_f) { Index: csv.q =================================================================== RCS file: /cvsroot/q-lang/q-csv/csv.q,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** csv.q 5 Mar 2008 22:04:02 -0000 1.17 --- csv.q 6 Mar 2008 16:19:08 -0000 1.18 *************** *** 20,24 **** /* The CSV library provides an interface to read and write comma separated value files. The reading and writing functions are loosely based on ! Python's csv module (http://docs.python.org/lib/module-csv.html) */ from dict import dict, insert, vals, member; --- 20,31 ---- /* The CSV library provides an interface to read and write comma separated value files. The reading and writing functions are loosely based on ! Python's csv module (http://docs.python.org/lib/module-csv.html) ! ! Bugfix: Wed Mar 5, 2008: Fixed EOF checking for freadcsvlist. ! Bugfix: Thr Mar 6, 2008: Dialect now defaults to '\n' on UNIX and OSX. ! Made Dialect the second option in tuple ! parameters for sread* and swrite*. ! Fixed various bugs. ! */ from dict import dict, insert, vals, member; *************** *** 94,101 **** EXCEL = csv_dialect [csv_quoting, csv_quote_none;]; ! /* Convert a tuple (record) to a CSV string. ! Dialect: CSV format specification. If none is given, defaults to the ! RFC4180 dialect. Rec: Tuple of fields to be converted to CSV format. --- 101,110 ---- EXCEL = csv_dialect [csv_quoting, csv_quote_none;]; ! public const var ! OS_DIALECT = ifelse (fnmatch "*mingw*" sysinfo) RFC4180 UNIX; ! /* Convert a tuple (record) to a CSV string. ! Dialect: CSV format specification. If none is given, defaults to ! RFC4180 for Windows and UNIX for all other OSs. Rec: Tuple of fields to be converted to CSV format. *************** *** 104,122 **** */ public swritecsv ARGS; ! swritecsv (Dialect:Tuple, Rec:Tuple) = tuple_to_csvstr Dialect Rec; swritecsv Rec:Tuple ! = tuple_to_csvstr RFC4180 Rec; /* Convert a list of tuples to a list of CSV formatted strings. */ public swritecsvlist ARGS; ! swritecsvlist (Dialect:Tuple, L:List) = map (tuple_to_csvstr Dialect) L; swritecsvlist L:List ! = map (tuple_to_csvstr RFC4180) L; /* Convert a tuple (record) to a CSV string ! Dialect: CSV format specification. If none is given, defaults to the ! RFC4180 dialect. Rec: Tuple of fields to be converted to CSV format. --- 113,131 ---- */ public swritecsv ARGS; ! swritecsv (Rec:Tuple, Dialect:Tuple) = tuple_to_csvstr Dialect Rec; swritecsv Rec:Tuple ! = tuple_to_csvstr OS_DIALECT Rec; /* Convert a list of tuples to a list of CSV formatted strings. */ public swritecsvlist ARGS; ! swritecsvlist (L:List, Dialect:Tuple) = map (tuple_to_csvstr Dialect) L; swritecsvlist L:List ! = map (tuple_to_csvstr OS_DIALECT) L; /* Convert a tuple (record) to a CSV string ! Dialect: CSV format specification. If none is given, defaults to ! RFC4180 for Windows and UNIX for all other OSs. Rec: Tuple of fields to be converted to CSV format. *************** *** 124,131 **** */ public sreadcsv ARGS; ! sreadcsv (Rec:Tuple, Dialect:Tuple) = csvstr_to_tuple Dialect Rec; ! sreadcsv Rec:Tuple ! = csvstr_to_tuple RFC4180 Rec; /* Convert a list of CSV formatted strings to a list of tuples */ --- 133,140 ---- */ public sreadcsv ARGS; ! sreadcsv (Rec:String, Dialect:Tuple) = csvstr_to_tuple Dialect Rec; ! sreadcsv Rec:String ! = csvstr_to_tuple OS_DIALECT Rec; /* Convert a list of CSV formatted strings to a list of tuples */ *************** *** 134,138 **** = map (csvstr_to_tuple Dialect) L; sreadcsvlist L:List ! = map (csvstr_to_tuple RFC4180) L; /* File handling functions */ --- 143,147 ---- = map (csvstr_to_tuple Dialect) L; sreadcsvlist L:List ! = map (csvstr_to_tuple OS_DIALECT) L; /* File handling functions */ *************** *** 141,145 **** = csvstr_to_tuple Dialect $ fread_csvstr F (Dialect!ord csv_quote); freadcsv F:File ! = csvstr_to_tuple RFC4180 $ fread_csvstr F "\""; public fwritecsv ARGS REC; --- 150,154 ---- = csvstr_to_tuple Dialect $ fread_csvstr F (Dialect!ord csv_quote); freadcsv F:File ! = csvstr_to_tuple OS_DIALECT $ fread_csvstr F "\""; public fwritecsv ARGS REC; *************** *** 147,154 **** = fwrites F $ tuple_to_csvstr Dialect Rec; fwritecsv F:File Rec:Tuple ! = fwrites F $ tuple_to_csvstr RFC4180 Rec; public freadcsvlist ARGS; ! freadcsvlist (F:File, Dialect:Tuple) = [] if feof F; = [freadcsv (F, Dialect) | freadcsvlist (F, Dialect)]; --- 156,163 ---- = fwrites F $ tuple_to_csvstr Dialect Rec; fwritecsv F:File Rec:Tuple ! = fwrites F $ tuple_to_csvstr OS_DIALECT Rec; public freadcsvlist ARGS; ! freadcsvlist (F:File, Dialect:Tuple,) = [] if feof F; = [freadcsv (F, Dialect) | freadcsvlist (F, Dialect)]; *************** *** 159,163 **** public fwritecsvlist ARGS REC; fwritecsvlist (F:File, Dialect:Tuple) L:List ! = do (fwritecsv F Dialect) L; fwritecsvlist F:File L:List = do (fwritecsv F) L; \ No newline at end of file --- 168,172 ---- public fwritecsvlist ARGS REC; fwritecsvlist (F:File, Dialect:Tuple) L:List ! = do (fwritecsv (F, Dialect)) L; fwritecsvlist F:File L:List = do (fwritecsv F) L; \ No newline at end of file |