使用 JSL 保存空表我從數據庫中打開幾個表,然後將它們保存到 CSV 文件中。 只要表有數據,腳本就可以正常工作,但是空表(我也想保存以顯示它們是空的)會給我這個錯誤:
數據表為空。
無法保存文件。
無法保存文件。{2}
我可以手動將表格保存為 JMP 格式,但不能導出為文本。 有任何想法嗎?回复:使用 JSL 保存空表在論壇中進一步閱讀後,我意識到 Is Empty() 函數並沒有說明表中是否有數據...... 我看到一個評論說最好使用 N Row (dt) 來做到這一點:
If( N Row( dt ) == 0,
// then
Print( "Data table is empty" );
// else
Print( "Data table is not empty" );
);
回复:使用 JSL 保存空表@中偉
我最近偶然發現了這個錯誤消息,感到非常驚訝。
然後我意識到我做了一張新桌子,裡面只有默認“第 1 列”,沒有行。
我希望將表保存為空表,但就我而言,解決方案就像在創建表時命名唯一的列一樣簡單。
原始報告顯然正在執行 NewTable() 函數之外的其他操作,因此命名列可能會更困難。
sentinelDt = New Table( "sentinel", "private", New Column( "a") ); // needs a col name to save it with no rows!
sentinelDt << save( root || sentinelName );
回复:使用 JSL 保存空表如果使用“Is Empty()”函數,則可以使用 if 語句僅在表不為空時保存數據:
例子:
dt = Open( "Path\DataTable" );
If( Is Empty( dt ),
// Then Do this if the table is not empty:
dt << Save( "Path\DataTable" )
,
// Else Do nothing
Print( "the table is empty and will not be saved" )
);