没有列名的数据表如何保存到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"))
)
);