| 
									
										
										
										
											2014-05-23 23:20:15 -04:00
										 |  |  | USING: help.markup help.syntax io.pathnames quotations strings ;
 | 
					
						
							| 
									
										
										
										
											2008-04-17 16:29:04 -04:00
										 |  |  | IN: csv | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | HELP: read-row | 
					
						
							| 
									
										
										
										
											2013-03-15 09:16:34 -04:00
										 |  |  | { $values { "row" "an array of fields" } } | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | { $description "parses a row from a csv stream" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: read-csv | 
					
						
							| 
									
										
										
										
											2013-03-15 09:16:34 -04:00
										 |  |  | { $values { "rows" "an array of arrays of fields" } } | 
					
						
							| 
									
										
										
										
											2009-01-30 20:23:04 -05:00
										 |  |  | { $description "Parses a csv stream into an array of row arrays." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: file>csv | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |     { "path" pathname } { "encoding" "an encoding descriptor" } | 
					
						
							|  |  |  |     { "csv" "csv" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Opens a file and parses it into a sequence of comma-separated-value fields." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: csv>file | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |     { "rows" "a sequence of sequences of strings" } | 
					
						
							|  |  |  |     { "path" pathname } { "encoding" "an encoding descriptor" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Writes a comma-separated-value structure to a file." } ;
 | 
					
						
							| 
									
										
										
										
											2008-04-17 16:29:04 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-25 19:30:40 -05:00
										 |  |  | HELP: string>csv | 
					
						
							|  |  |  | { $values | 
					
						
							|  |  |  |     { "string" string } | 
					
						
							|  |  |  |     { "csv" "csv" } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Parses a string into a sequence of comma-separated-value fields." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: csv>string | 
					
						
							|  |  |  | { $values | 
					
						
							| 
									
										
										
										
											2010-02-27 14:04:42 -05:00
										 |  |  |     { "csv" "csv" } | 
					
						
							| 
									
										
										
										
											2010-02-25 19:30:40 -05:00
										 |  |  |     { "string" string } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $description "Writes a comma-separated-value structure to a string." } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | HELP: write-row | 
					
						
							|  |  |  | { $values { "row" "an array of fields" } } | 
					
						
							|  |  |  | { $description "writes a row to the output stream" } ;
 | 
					
						
							| 
									
										
										
										
											2008-04-30 12:50:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-25 17:02:07 -04:00
										 |  |  | HELP: write-csv | 
					
						
							| 
									
										
										
										
											2013-03-15 09:16:34 -04:00
										 |  |  | { $values { "rows" "a sequence of sequences of strings" } } | 
					
						
							| 
									
										
										
										
											2009-01-30 20:23:04 -05:00
										 |  |  | { $description "Writes a sequence of sequences of comma-separated-values to the output stream, escaping where necessary." } ;
 | 
					
						
							| 
									
										
										
										
											2008-04-30 12:50:40 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: with-delimiter | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | { $values { "ch" "field delimiter (e.g. CHAR: \\t)" } | 
					
						
							| 
									
										
										
										
											2014-05-23 23:20:15 -04:00
										 |  |  |           { "quot" quotation } } | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | { $description "Sets the field delimiter for read-csv, read-row, write-csv, or write-row words." } ;
 | 
					
						
							| 
									
										
										
										
											2009-01-30 20:23:04 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ARTICLE: "csv" "Comma-separated-values parsing and writing" | 
					
						
							|  |  |  | "The " { $vocab-link "csv" } " vocabulary can read and write CSV (comma-separated-value) files." $nl | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | "Working with CSV files:" | 
					
						
							|  |  |  | { $subsections file>csv csv>file } | 
					
						
							|  |  |  | "Working with CSV strings:" | 
					
						
							|  |  |  | { $subsections string>csv csv>string } | 
					
						
							| 
									
										
										
										
											2009-01-30 20:23:04 -05:00
										 |  |  | "Changing the delimiter from a comma:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections with-delimiter } | 
					
						
							| 
									
										
										
										
											2009-01-30 20:23:04 -05:00
										 |  |  | "Reading from a stream:" | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | { $subsections read-csv read-row } | 
					
						
							| 
									
										
										
										
											2009-01-30 20:23:04 -05:00
										 |  |  | "Writing to a stream:" | 
					
						
							| 
									
										
										
										
											2013-03-15 00:05:41 -04:00
										 |  |  | { $subsections write-csv write-row } ;
 | 
					
						
							| 
									
										
										
										
											2008-07-25 17:02:07 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-30 20:23:04 -05:00
										 |  |  | ABOUT: "csv" |