從文字檔案匯入資料的問題我們在從文字檔案匯入資料時遇到了問題。現在,某些列出現了錯誤訊息(「匯入列時遇到無效資料…請嘗試重新匯入數據,但請明確將這些列的資料類型設為字元」)。
為了更好地說明,我們有一個 JMP 腳本,用於從資料庫中提取大量資料。提取後,資料將根據每個資料實例的列和行中的參數進行組織。這些參數都是分類的,但也有很多是數值型的(很多是日期格式的)。幾年前,我們尋求協助來提高效能(時間),將所有列轉換為適當的資料類型(使用 JMP 腳本花費了大量時間,因為有數千列)。
Jim Nelson 建議將表格儲存為文字文件,然後再開啟。這個方法效果很好,性能得到了顯著提升,所有列都轉換為數字格式,並且保留了日期格式。
現在,這不再起作用,並且視窗警報停止執行。
我查看了社區,嘗試了一種建議的方法:
collist = dt << Get Column Names("String");
For Each({colname}, collist,
r = Column(dt, colname) << Set Data Type("Numeric", << Fail On Conversion Error, <
<RETURN failed="" rows=""></RETURN>
<P>這不太好,因為我們遺失了日期格式,所以應該是日期的欄位以數字格式出現。</P> <P>有人能建議一種解決方法嗎?</P>
<LINGO-LABS id="lingo-labs-909378" slang="en-US" mode="CREATE">
<LINGO-LABEL>自動化和腳本</LINGO-LABEL>
</LINGO-LABS>
回覆:從文字檔案匯入資料的問題什麼變化導致過程停止運作?
您使用的 JMP 是什麼版本?
什麼作業系統?
您能否提供您正在讀取的文字檔案的範例以及您用來執行此操作的 JSL?
回覆:從文字檔案匯入資料的問題I'm using JMP PRO ver 18.0.0 (JMP normal show the same behavior).
Operating system : Windows 10 Enterprise
What I changed is the instruction open("C:\TEMP\jmp_conversion.csv", columns(LOT_ID=character), scan whole file(1));
where I added the clause columns(LOT_ID=character). Without this change it works (but in some specific case the lot_id is converted numeric in scientific notation: the reason for the change).
Consider that if you run just the following script you do not receive the blocking alert but a message in the log. (I don't know why)
numeric_conversion = function({dt},{Default Local},
n= dt << get name();
try(delete file("C:\TEMP\jmp_conversion.csv"));
dt << save as("C:\TEMP\jmp_conversion.csv");
close(dt,nosave);
try(
dt= open("C:\TEMP\jmp_conversion.csv", columns(LOT_ID=character), scan whole file(1));
);
dt << set name(n);
return(dt);
);
dt= data table("ExtractedData");
dt = dt << split(
split( :VALUE ),
split by( :PARAM ),
group( :LOT_ID, :WAFER_NO ),
remaining Columns( Keep All ),
);
dt = numeric_conversion(dt);
回覆:從文字檔案匯入資料的問題腳本運作正常,JMP 也確實會告訴你日誌訊息的原因
Invalid data encountered while importing the column Reactor.
25 values were set to missing.
Try importing the data again, but explicitly set the Data Type of those columns to Character.
這是由於 Reactor 列中缺少字元值所造成的。如果您想避免這種情況,可以將 Open 函數包裝在 Log Capture() 函數中。
Names Default To Here(1);
numeric_conversion = Function({dt_split}, {Default Local},
n = dt_split << get name();
Try(Delete File("C:\TEMP\jmp_conversion.csv"));
dt_split << Save As("C:\TEMP\jmp_conversion.csv");
Close(dt_split, nosave);
Log Capture(dt_split = Open("C:\TEMP\jmp_conversion.csv", columns(LOT_ID = character), scan whole file(1)));
dt_split << set name(n);
Return(dt_split);
);
dt = Open("$DOWNLOADS/ExtractedData.jmp");
dt_split = dt << split(split(:VALUE), split by(:PARAM), group(:LOT_ID, :WAFER_NO), remaining Columns(Keep All), Output table("ExtractedData Split"));
Close(dt, no save);
dt_split = numeric_conversion(dt_split);