Subscribe Bookmark RSS Feed

get a value from a table and save as a csv file

newuser

Community Trekker

Joined:

Jan 19, 2016

I have a table and I would like to grab a single value from a certain cell and then save the value as a csv file to use in excel

5 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Here is a simple script that does what you indicated you want:

names default to here(1);

dt=open("$SAMPLE_DATA\Big Class.jmp");

single value = dt:name[5];

save text file("C:\Temp\Sample.csv",single value);

If the single value you are saving is a numeric value, then just use a format() function to convert it.

save text file("C:\Temp\Sample.csv",format(single value,"Fixed Dec",5,2));

Jim
newuser

Community Trekker

Joined:

Jan 19, 2016

Hi Jim,

Thanks for the help,

I keep getting the following error when I try save the value:

Name Unresolved: Save Text File{1} in function 'Save Text File', Save Text File("C:\data\value.csv", value)

This is the code:

dt = current data table();

value = dt:RDIStoWDIS[1];

show (value);

Save Text File("C:\data\value.csv",value);

I can see the value in the log by using the show() function but the save itself isnt working.

txnelson

Super User

Joined:

Jun 22, 2012

What is displayed in the log for the variable "Value" from your "show(value)"?

Does the folder "C:\data" exists?

Remember, the variable value needs to be a character string.

Jim
newuser

Community Trekker

Joined:

Jan 19, 2016

C:\data exists.

A number.

txnelson

Super User

Joined:

Jun 22, 2012

change your "Save Text File" function to:

save text file(("C:\data\value.csv",format(single value,"Fixed Dec",5,2));

The numeric value needs to be converted to a character string to be written out using save text file.

Jim