DolphinDB Java API 和 GUI 中函数 运行 的不同输出
Different output of function run in DolphinDB Java API and GUI
脚本是:
conn.login("admin","123456",false);
StringBuilder sb = new StringBuilder();
sb.append("'")
.append("F:"+File.separator+"dolphinDB2"+File.separator+"DolphinDB_GUI_V1.30.13"+File.separator+"workspace"+File.separator+"test1"+File.separator+"scripts"+File.separator+"GenTradeTable.txt")
.append("'") ;
Entity run = conn.run(sb.toString());
System.out.println("run.getString():"+run.getString());
txt 文件是
n=2000
syms=`YHOO`GE`MS`MSFT`JPM`ORCL`CISCO
timestamp=09:30:00+rand(18000, n)
sym=rand(syms, n)
qty=100*(1+rand(100,n))
price=5.0+rand(100.0, n)
t1=table(timestamp,sym,qty,price);
t1
结果在 DolphinDB GUI 中按预期打印,但是 Java API 只有 returns txt 文件的路径。
对于DolphinDBJavaAPI,run
方法的参数是一个字符串脚本,不同于built-in函数run
。
更正后的脚本是:
DBConnection conn = new DBConnection();
conn.connect("localhost",8848,"admin","123456");
StringBuilder sb = new StringBuilder();
String script = "run(\"D:/work/GenTradeTable.txt\")";
System.out.println(script);
BasicTable res = (BasicTable) conn.run(script);
System.out.println("run.getString():"+res.getString());
脚本是:
conn.login("admin","123456",false);
StringBuilder sb = new StringBuilder();
sb.append("'")
.append("F:"+File.separator+"dolphinDB2"+File.separator+"DolphinDB_GUI_V1.30.13"+File.separator+"workspace"+File.separator+"test1"+File.separator+"scripts"+File.separator+"GenTradeTable.txt")
.append("'") ;
Entity run = conn.run(sb.toString());
System.out.println("run.getString():"+run.getString());
txt 文件是
n=2000
syms=`YHOO`GE`MS`MSFT`JPM`ORCL`CISCO
timestamp=09:30:00+rand(18000, n)
sym=rand(syms, n)
qty=100*(1+rand(100,n))
price=5.0+rand(100.0, n)
t1=table(timestamp,sym,qty,price);
t1
结果在 DolphinDB GUI 中按预期打印,但是 Java API 只有 returns txt 文件的路径。
对于DolphinDBJavaAPI,run
方法的参数是一个字符串脚本,不同于built-in函数run
。
更正后的脚本是:
DBConnection conn = new DBConnection();
conn.connect("localhost",8848,"admin","123456");
StringBuilder sb = new StringBuilder();
String script = "run(\"D:/work/GenTradeTable.txt\")";
System.out.println(script);
BasicTable res = (BasicTable) conn.run(script);
System.out.println("run.getString():"+res.getString());