匯入具有多個“其他”分隔符號的文件JMP Pro 13。我正在嘗試導入 .dat 檔案。 每列都是數字。 每行都以 ( ) 開頭,以 ) 結尾,所以我似乎無法弄清楚如何在導入時刪除這兩個符號。 問題是我似乎無法擺脫尾隨 ) ,因此該列作為字元導入。 即使我設定腳本來替換 ) ,但該列仍然是字符,我不知道如何強制它為數字。
For( i = 1, i<= n rows(dtSFileMasterModule), i++,
dtSPMFile = Open( PMxPath || PMx[i] ||"\file.dat", Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Space, Other( "(" ), CSV( 0 ) ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Use Regional Settings( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
CompressNumericColumns( 0 ),
CompressCharacterColumns( 0 ),
CompressAllowListCheck( 0 ),
Labels( 1 ),
Column Names Start( 3 ),
Data Starts( 4 ),
Lines To Read( "All" ),
Year Rule( "20xx" )));
dtSPMxFileMaster = dtSPMxFileMaster << concatenate(dtSPMFile, append to first table(1));
Close( dtSPMFile, "no save" );
);回覆:匯入帶有多個「其他」分隔符號的文件糟糕,我忘記從要子集化的字串長度中減去“1”。 代碼應該是:
Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i] = Substr(
Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i],
1,
Contains( Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i], ")" ) - 1
)
回覆:匯入帶有多個「其他」分隔符號的文件這看起來非常非常接近。 我遇到的一個問題是整個單元格都被刪除,而不僅僅是右括號。 例如,該儲存格包含像 26.1234 這樣的數字,我只想剪掉右括號。 您提供的腳本會刪除單元格,但我認為您並不是故意這樣做的,對嗎?
我可以用“7”替換腳本中的字串,以在第 7 位數字之後修剪它,但是如果資料更改為其他字串長度,則這會使腳本不太靈活。 這很可能會起作用,但如果你有任何建議,我會支持的! 謝謝!!!
For( i = 1, i <= N Rows( dtSPMxFileMaster ), i++,
Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i] = Substr(Column(
dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i],
1,
7 )
);
// Change the last column to numeric and continuous
Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) ) << data type( numeric ) << modeling type( continuous );
回覆:匯入帶有多個「其他」分隔符號的文件我相信,如果您在連接所有單獨的數據表之後添加此內容,它將糾正該問題
// Loop through all rows and get rid of the ")" on the last column
For( i = 1, I <= N Rows( dtSPMxFileMaster ), i++,
Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i] = Substr(
Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i],
1,
Contains( Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) )[i], ")" )
)
);
// Change the last column to numeric and continuous
Column( dtSPMxFileMaster, N Cols( dtSPMxFileMaster ) ) << data type( numeric ) << modeling type( continuous );