[rkward-cvs] SF.net SVN: rkward: [2155] trunk/rkward/rkward/plugins/00saveload/import

kapatp at users.sourceforge.net kapatp at users.sourceforge.net
Fri Nov 2 08:02:25 UTC 2007


Revision: 2155
          http://rkward.svn.sourceforge.net/rkward/?rev=2155&view=rev
Author:   kapatp
Date:     2007-11-02 01:02:24 -0700 (Fri, 02 Nov 2007)

Log Message:
-----------
Modified Import Text/CSV plugin using read.{csv,csv2,delim,delim2}

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/00saveload/import/import_csv.php
    trunk/rkward/rkward/plugins/00saveload/import/import_csv.xml

Modified: trunk/rkward/rkward/plugins/00saveload/import/import_csv.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/import_csv.php	2007-10-31 14:29:18 UTC (rev 2154)
+++ trunk/rkward/rkward/plugins/00saveload/import/import_csv.php	2007-11-02 08:02:24 UTC (rev 2155)
@@ -8,14 +8,23 @@
 }
 
 function calculate () {
-	$dec = getRK_val ("dec");
-	if ($dec == "other") $dec = quoteString (getRK_val ("custom_dec"));
-	$sep = getRK_val ("sep");
-	if ($sep == "other") $sep = quoteString (getRK_val ("custom_sep"));
-	$quote = getRK_val ("quote");
-	if ($quote == "other") $quote = quoteString (getRK_val ("custom_quote"));
-
-getRK("name"); ?> <<- read.table (file="<? getRK("file"); ?>", header=<? getRK("header"); ?>, sep=<? echo ($sep); ?>, quote=<? echo ($quote); ?>, dec=<? echo ($dec); ?>, <? # doing row names (what a pity...) 
+	$quick = getRK_val ("quick");
+	if ($quick == "table") {
+		$dec = getRK_val ("dec");
+		if ($dec == "other") $dec = quoteString (getRK_val ("custom_dec"));
+		$sep = getRK_val ("sep");
+		if ($sep == "other") $sep = quoteString (getRK_val ("custom_sep"));
+		$quote = getRK_val ("quote");
+		if ($quote == "other") $quote = quoteString (getRK_val ("custom_quote"));
+		$header = getRK_val ("header");
+		$fill = getRK_val ("fill");
+		$comchar = quoteString (getRK_val ("commentchar"));
+		$tableOptions = ", header={$header}, sep={$sep}, quote={$quote}, dec={$dec}, fill={$fill}, comment.char={$comchar}";
+	} else {
+		$tableOptions = "";
+	}
+// Other method is to use read.table and show all the options - more transparent
+getRK("name"); ?> <<- read.<? echo ($quick); ?> (file="<? getRK("file"); ?>"<? echo ($tableOptions); ?>, <? # doing row names (what a pity...) 
 	if (getRK_val("rowname")!="NULL") {
 		echo( "row.names = ");
 		if (getRK_val("rowname")=="rowcol") echo (getRK("nomrow") . ",");
@@ -26,7 +35,7 @@
 	# doing col class (what a pity...)
 	if (getRK_val("colclass") == "custoClass") echo( "colClasses = " . getRK_val ("custoClasses") . ",");
 	#doing what is left
-?> na.strings = "<? getRK("na")  ?>", nrows = <? getRK("nrows") ; ?>, skip = <? getRK("skip") ; ?>, check.names = <? getRK("checkname") ; ?>, fill = <? getRK("fill") ; ?>, strip.white = <? getRK("stripwhite") ; ?>, blank.lines.skip = <? getRK("blanklinesskip") ; ?>, comment.char=<? echo (quoteString (getRK_val("commentchar"))); ?><? getRK("allow_escapes"); ?><? getRK("flush"); ?><? getRK("strings_as_factors"); ?>)
+?> na.strings = "<? getRK("na")  ?>", nrows = <? getRK("nrows") ; ?>, skip = <? getRK("skip") ; ?>, check.names = <? getRK("checkname") ; ?>, strip.white = <? getRK("stripwhite") ; ?>, blank.lines.skip = <? getRK("blanklinesskip") ; ?><? getRK("allow_escapes"); ?><? getRK("flush"); ?><? getRK("strings_as_factors"); ?>)
 <?	if (getRK_val ("doedit")) { ?>
 
 rk.edit (<? getRK ("name"); ?>)

Modified: trunk/rkward/rkward/plugins/00saveload/import/import_csv.xml
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/import_csv.xml	2007-10-31 14:29:18 UTC (rev 2154)
+++ trunk/rkward/rkward/plugins/00saveload/import/import_csv.xml	2007-11-02 08:02:24 UTC (rev 2155)
@@ -6,20 +6,54 @@
 		<external id="filename" />
 		<connect governor="filename" client="file.selection"/>
 
-		<connect client="rowname.enabled" governor="isrow.state" />
-
-		<convert id="customsep" mode="equals" sources="sep.string" standard="other" />
-		<connect client="custom_sep.enabled" governor="customsep" />
-		<connect client="custom_sep.required" governor="custom_sep.enabled" />
-
+		<convert id="quickNone" mode="equals" sources="quick.string" standard="table" />
+		<convert id="quickCSV" mode="equals" sources="quick.string" standard="csv" />
+		<convert id="quickCSV2" mode="equals" sources="quick.string" standard="csv2" />
+		<convert id="quickTAB" mode="equals" sources="quick.string" standard="delim" />
+		<convert id="quickTAB2" mode="equals" sources="quick.string" standard="delim2" />
+		<convert id="quickCC2TT2" mode="notequals" sources="quick.string" standard="table" />
+		
+		<connect client="header.enabled" governor="quickNone" />
+		<connect client="header.state" governor="quickCC2TT2" />
+		<connect client="fill.state" governor="quickCC2TT2" />
+		<connect client="commentchar.enabled" governor="quickNone" />
+		<connect client="fill.enabled" governor="quickNone" />
+		
+		<convert id="quickNCT" mode="or" sources="quickNone;quickCSV;quickTAB"/>
+		<connect client="dec.decPeriod.enabled" governor="quickNCT" />
+		<convert id="quickNC2T2" mode="or" sources="quickNone;quickCSV2;quickTAB2"/>
+		<connect client="dec.decComma.enabled" governor="quickNC2T2" />
+		<connect client="dec.decOther.enabled" governor="quickNone" />
+		
 		<convert id="customdec" mode="equals" sources="dec.string" standard="other" />
 		<connect client="custom_dec.enabled" governor="customdec" />
 		<connect client="custom_dec.required" governor="custom_dec.enabled" />
 		
+		<convert id="quickNTT2" mode="or" sources="quickNone;quickTAB;quickTAB2"/>
+		<connect client="sep.sepTab.enabled" governor="quickNTT2" />
+		
+		<convert id="quickNC2" mode="or" sources="quickNone;quickCSV2"/>
+		<connect client="sep.sepSemiC.enabled" governor="quickNC2" />
+		<convert id="quickNC" mode="or" sources="quickNone;quickCSV"/>
+		<connect client="sep.sepComma.enabled" governor="quickNC" />
+		<connect client="sep.sepSpace.enabled" governor="quickNone" />
+		<connect client="sep.sepOther.enabled" governor="quickNone" />
+		
+		<convert id="customsep" mode="equals" sources="sep.string" standard="other" />
+		<connect client="custom_sep.enabled" governor="customsep" />
+		<connect client="custom_sep.required" governor="custom_sep.enabled" />
+		
+		<connect client="quote.quoteSingQ.enabled" governor="quickNone" />
+		<connect client="quote.quoteDoubQSingQ.enabled" governor="quickNone" />
+		<connect client="quote.quoteNone.enabled" governor="quickNone" />
+		<connect client="quote.quoteOther.enabled" governor="quickNone" />
+		
 		<convert id="customquote" mode="equals" sources="quote.string" standard="other" />
 		<connect client="custom_quote.enabled" governor="customquote" />
 		<connect client="custom_quote.required" governor="custom_quote.enabled" />
 
+		<connect client="rowname.enabled" governor="isrow.state" />
+		
 		<convert id="userow" mode="equals" sources="rowname.string" standard="rowcol" />
 		<convert id="customizerow" mode="equals" sources="rowname.string" standard="custoRow" />
 		<convert id="customizerow2" mode="and" sources="isrow.state;customizerow" standard="custoRow" />
@@ -38,90 +72,104 @@
 	<dialog label="Import Text / CSV data" >
 		<tabbook>
 			<tab id="tab_general" label="General" >
-				<browser id="file" type="file" label="File name" />
+				<browser id="file" type="file" label="File name"/>
 				<row>
 					<saveobject id="name" initial="my.csv.data" label="Object to save to"/>
 					<checkbox id="doedit" value="1" value_unchecked="0" label="Edit Object" checked="true" />
 				</row>
-				<checkbox id="header" value="TRUE" value_unchecked="FALSE" checked="true" label="First row contains column names"/>
 				<row>
 					<column>
+						<radio id="quick" label="Quick mode" >
+							<option value="table" label="None" checked="true"/>
+							<option value="csv" label="CSV" />
+							<option value="csv2" label="CSV2" />
+							<option value="delim" label="TAB" />
+							<option value="delim2" label="TAB2" />
+						</radio>
+					</column>
+					<column>
+						<checkbox id="header" value="TRUE" value_unchecked="FALSE" checked="false" label="Column names in first row"/>
 						<radio id="dec" label="Decimal point character" >
-							<option value="'.'" label="'.'" />
-							<option value="','" label="','" />
-							<option value="other" label="Other (specify below)" />
+							<option id="decPeriod" value="'.'" label="'.' (Period)" />
+							<option id="decComma" value="','" label="',' (Comma)" />
+							<option id="decOther" value="other" label="Other (specify below)" />
 						</radio>
 						<input id="custom_dec" label="Specify decimal point character" />
 					</column>
 					<column>
 						<radio id="sep" label="Field separator character" >
-							<option value="'\t'" label="Tab" />
-							<option value="';'" label="';'" />
-							<option value="','" label="','" />
-							<option value="' '" label="Space" />
-							<option value="other" label="Other (specify below)" />
+							<option id="sepTab" value="'\t'" label="Tab" />
+							<option id="sepSemiC" value="';'" label="';' (Semicolon)" />
+							<option id="sepComma" value="','" label="',' (Comma)" />
+							<option id="sepSpace" value="' '" label="Space" />
+							<option id="sepOther" value="other" label="Other (specify below)" />
 						</radio>
 						<input id="custom_sep" label="Specify field separator character" />
 					</column>
 				</row>
 			</tab>
-			<tab id="tab_rows" label="Rows" >
-				<checkbox value_unchecked="false" checked="false" value="true" id="isrow" label="Customize row names" />
-				<radio id="rowname" label="Rows names" >
-					<option value="NULL" label="Number" />
-					<option value="rowcol" label="As specified in column x:" />
-					<option value="custoRow" label="Use a vector" />
-				</radio>
-				<input size="small" id="nomrow" initial="1" label="Column number or variable name" />
-				<input id="rownames" label="Vector of row names (quoted)" />
+			<tab id="tab_rows" label="Rows and Columns" >
+				<row>
+					<column>
+						<frame label="Row Specifications">
+							<checkbox value_unchecked="false" checked="false" value="true" id="isrow" label="Customize row names" />
+							<radio id="rowname" label="Rows names" >
+								<option value="NULL" label="Number" />
+								<option value="rowcol" label="As specified in column x:" />
+								<option value="custoRow" label="Use a vector" />
+							</radio>
+							<input size="small" id="nomrow" initial="1" label="Column number or variable name" />
+							<input id="rownames" label="Vector of row names (quoted)" />
+						</frame>
+					</column>
+					<column>
+						<frame label="Column Specifications">
+							<radio id="colname" label="Column names" >
+								<option value="" label="Default" />
+								<option value="custoCol" label="Use a character vector" />
+							</radio>
+							<input id="colnames" label="Vector of column names (quoted)" />
+						<checkbox id="flush" label="Skip any further fields" value=", flush=TRUE" value_unchecked="" />
+							<radio id="colclass" label="Classes of columns" >
+								<option value="" label="Default" />
+								<option value="custoClass" label="Use a character vector" />
+							</radio>
+							<input id="custoClasses" label="Vector of column classes (quoted)" />
+						</frame>
+					</column>
+				</row>
 			</tab>
-			<tab id="tab_columns"  label="Columns" >
-				<frame label="Column names">
-					<radio id="colname" label="Column names" >
-						<option value="" label="Default" />
-						<option value="custoCol" label="Use a character vector" />
+			
+			<tab id="tab_further_options" label="Further Options" >
+				<row>
+				<column>
+					<checkbox id="allow_escapes" label="Allow escaped characters" value=", allowEscapes=TRUE" value_unchecked="" />
+					<radio id="strings_as_factors" label="Convert character columns to factors" >
+						<option value=", stringsAsFactors=TRUE" label="Convert to factor" />
+						<option value="" label="Default" checked="true" />
+						<option value=", stringsAsFactors=FALSE" label="Do not convert" />
 					</radio>
-					<input id="colnames" label="Vector of column names (quoted)" />
-				</frame>
-				<checkbox id="flush" label="Skip any further fields" value=", flush=TRUE" value_unchecked="" />
-				<frame label="Column classes">
-					<radio id="colclass" label="Classes of columns" >
-						<option value="" label="Default" />
-						<option value="custoClass" label="Use a character vector" />
+					<radio id="quote" label="String delimiter" >
+						<option id="quoteDoubQ" value="'\"'" label="" only" />
+						<option id="quoteSingQ" value="'\''" label="' only" />
+						<option id="quoteDoubQSingQ" value="'"\''" label="" and '" checked="true"/>
+						<option id="quoteNone" value="''" label="None / disabled" />
+						<option id="quoteOther" value="other" label="Other (specify below)" />
 					</radio>
-					<input id="custoClasses" label="Vector of column classes (quoted)" />
-				</frame>
+					<input id="custom_quote" label="Specify quoting character(s)" />
+				</column>
+				<column>
+						<input size="small" initial="0" id="skip" label="Skip x lines at the start of the file" />
+						<input size="small" initial="-1" id="nrows" label="Max number of lines to read (-1 for no limit)" />
+						<input size="small" initial="NA" id="na" label="Character for missing values" />
+						<input size="small" initial="#" id="commentchar" label="Character for comments" />
+					<checkbox id="fill" checked="false" value="TRUE" value_unchecked="FALSE" label="Fill the rows if unequal length" />
+					<checkbox value_unchecked="FALSE" checked="true" value="TRUE" id="checkname" label="Check syntax of the variables names" />
+					<checkbox value_unchecked="FALSE" checked="false" value="TRUE" id="stripwhite" label="Strip white values" />
+					<checkbox value_unchecked="FALSE" checked="true" value="TRUE" id="blanklinesskip" label="Skip blank lines" />
+				</column>
+			</row>
 			</tab>
-			<tab id="tab_strings"  label="Strings" >
-				<checkbox id="allow_escapes" label="Allow escaped characters" value=", allowEscapes=TRUE" value_unchecked="" />
-				<radio id="strings_as_factors" label="Convert character columns to factors" >
-					<option value=", stringsAsFactors=TRUE" label="Convert to factor" />
-					<option value="" label="Default" checked="true" />
-					<option value=", stringsAsFactors=FALSE" label="Do not convert" />
-				</radio>
-				<radio id="quote" label="String delimiter" >
-					<option value="'"'" label="" only" />
-					<option value="'\''" label="' only" />
-					<option value="'"\''" label="" and '" checked="true"/>
-					<option value="''" label="None / disabled" />
-					<option value="other" label="Other (specify below)" />
-				</radio>
-				<input id="custom_quote" label="Specify quoting character(s)" />
-			</tab>
-			<tab id="tab_further_options" label="Further Options" >
-				<row>
-					<input size="small" initial="0" id="skip" label="Skip x lines at the start of the file" />
-					<input size="small" initial="-1" id="nrows" label="Max number of lines to read (-1 for no limit)" />
-				</row>
-				<row>
-					<input size="small" initial="NA" id="na" label="Character for missing values" />
-					<input size="small" initial="#" id="commentchar" label="Character for comments" />
-				</row>
-				<checkbox id="fill" checked="false" value="TRUE" value_unchecked="FALSE" label="Fill the rows if unequal length" />
-				<checkbox value_unchecked="FALSE" checked="true" value="TRUE" id="checkname" label="Check syntax of the variables names" />
-				<checkbox value_unchecked="FALSE" checked="false" value="TRUE" id="stripwhite" label="Strip white values" />
-				<checkbox value_unchecked="FALSE" checked="true" value="TRUE" id="blanklinesskip" label="Skip blank lines" />
-			</tab>
 		</tabbook>
 	</dialog>
 </document>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list