沒有列名的數據表如何保存到TXT?大家好:
沒有列名的數據表如何保存到TXT?謝謝!
Re: 如何將沒有列名的數據表保存到TXT?你好,
由於我需要將某些字符串鏈保存在文本文件中的不同行中,因此我嘗試了上述 txnelson 一對一的解決方案,但是它返回了一個文件,但字符串鏈保存在一行中。 在我的案例中,換行符似乎沒有帶來預期的效果。 我錯過了什麼?
最好的祝福
編輯:
好的,而不是"\!n"我寫“\!r\!n”然後按需要工作。
Re: 如何將沒有列名的數據表保存到TXT?這是一個傑作。 非常感謝你!Re: 如何將沒有列名的數據表保存到TXT?另一種方法是更改您的導出首選項,保存文件並返回默認首選項。
下面的腳本包含這些步驟。 它記錄在 JSL Companion,第 2 版中。腳本 2_Extra_SaveText.jsl
Names Default to Here(1);
//Get a copy of the user's settings
_xx = Get Preference( Export settings);
//set the text export preferences you want
Preference(
Export Settings(
End Of Line( CRLF ),
End Of Field( Comma, CSV( 1 ) ),
Export Table Headers( 0 ),
Quote all column names( 0 ),
Quote all character values( 0 ),
Quote all numeric values( 0 )
)
);
//you can look at preferences now an they will be changed.
dt = Open("$Sample_data/Big Class.jmp");
dt << Save("c:/temp/bclass.txt");
//reset the user's preferences
_xx;Re: 如何將沒有列名的數據表保存到TXT?我也需要解決這個問題。 非常感謝 txnelson 的解決方案。
Re: 如何將沒有列名的數據表保存到TXT?謝謝吉姆!
就這樣一直循環下去。VBA中也是如此。Re: 如何將沒有列名的數據表保存到TXT?這是一個簡單的腳本,可以做你想做的事
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
// Loop across all rows
For( i = 1, i <= N Rows( dt ), i++,
// Copy all columns for the given row into a list
rowVals = dt[i, 0];
// Initialize a string variable
theString = "";
// Loop across all values in the row list, and place them into the string variable
For( k = 1, k <= N Items( rowVals ), k++,
If( k > 1,
// After the first value, add a comma between the values
theString = theString || ","
);
theString = theString || char(rowVals[k]);
);
// Add a new line character at the end of the line
theString=theString||"\!n";
// Write the row's values to the output txt file
If(i==1,
save text file("$TEMP/myfile.txt",theString,mode("replace")),
save text file("$TEMP/myfile.txt",theString,mode("append"))
)
);