Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
SIBH
Level I

File save as .csv format keeps failing from version to version

Dear All,

I have one script to save data table automatically as .csv. This works for few JMP14 or 15 users, but fails for few JMP15 users. same script runs behind all types of data table save. I tried both, with or without 'convert file path' but cant get to the real reason behind it.
Thanks ! Simanti.

save_csv_file = Function({dt},
	try(
		path = Pick Directory ("Select a directory.");
		print(path);
		New Window( "Specify filename",
			<<Modal,
			file_name = Text Edit Box( "", <<Justify Text( Center ), << Set Width(200) );
		);
		name_dt = file_name << Get Text();
		
		dt << Save As (Convert File Path( path || name_dt || ".csv")); //this is working
		//dt << Save As ( path || name_dt || ".csv"); // this is working too :)
		
		//print(path || name_dt || ".csv");
		New Window( "Success!",
		<<Modal,Text Box("Your file was saved with success!"));,
		New Window( "Ups!",
		<<Modal,Text Box("We were unable to save your file, try again!"));
	);
);
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: File save as .csv format keeps failing from version to version

The section of the code

New Window( "Specify filename",
			<<Modal,
			file_name = Text Edit Box( "", <<Justify Text( Center ), << Set Width(200) );
		);
		name_dt = file_name << Get Text();

fails in JMP 15 for me. But if you change the code to:

save_csv_file = Function({dt},
	try(
		path = Pick Directory ("Select a directory.");
		print(path);
		New Window( "Specify filename",
			<<Modal,
			file_name = Text Edit Box( "", <<Justify Text( Center ), << Set Width(200),
			<<set script(name_dt = file_name << Get Text();) );
		);	
		dt << Save As ( path || name_dt || ".csv"); //this is working
		//dt << Save As ( path || name_dt || ".csv"); // this is working too :)
		
		//print(path || name_dt || ".csv");
		New Window( "Success!",
		<<Modal,Text Box("Your file was saved with success!"));,
		New Window( "Ups!",
		<<Modal,Text Box("We were unable to save your file, try again!"));
	);
);

it works in both 14 and 15

Jim

View solution in original post

6 REPLIES 6
Highlighted
Thierry_S
Level VI

Re: File save as .csv format keeps failing from version to version

Hi,
Is it possible that the Save As command fails because a file with the same name exists in the target directory? If it is a possibility, you may want to test if the file exists (File Exist (path)) to let the user know.
Just a thought.
Best,
TS
Thierry R. Sornasse
Highlighted

Re: File save as .csv format keeps failing from version to version

Adding to @Thierry_S's suggestion, what if you isolate the Save As() message (forget the function for now) and make sure that it works on its own?

Learn it once, use it forever!
Highlighted
SIBH
Level I

Re: File save as .csv format keeps failing from version to version

Hi @markbailey , This function separately is working in my system and few other person's system too. I will check it in the system of the people who have fail issues. Thank you, Simanti 

Highlighted
txnelson
Super User

Re: File save as .csv format keeps failing from version to version

The section of the code

New Window( "Specify filename",
			<<Modal,
			file_name = Text Edit Box( "", <<Justify Text( Center ), << Set Width(200) );
		);
		name_dt = file_name << Get Text();

fails in JMP 15 for me. But if you change the code to:

save_csv_file = Function({dt},
	try(
		path = Pick Directory ("Select a directory.");
		print(path);
		New Window( "Specify filename",
			<<Modal,
			file_name = Text Edit Box( "", <<Justify Text( Center ), << Set Width(200),
			<<set script(name_dt = file_name << Get Text();) );
		);	
		dt << Save As ( path || name_dt || ".csv"); //this is working
		//dt << Save As ( path || name_dt || ".csv"); // this is working too :)
		
		//print(path || name_dt || ".csv");
		New Window( "Success!",
		<<Modal,Text Box("Your file was saved with success!"));,
		New Window( "Ups!",
		<<Modal,Text Box("We were unable to save your file, try again!"));
	);
);

it works in both 14 and 15

Jim

View solution in original post

Highlighted
SIBH
Level I

Re: File save as .csv format keeps failing from version to version

Thank you @txnelson , now the script is working perfectly, with the changes you've suggested.

Thank you again.

Highlighted
SIBH
Level I

Re: File save as .csv format keeps failing from version to version

Thank you @Thierry_S, that is very relevant suggestion, I will include it. However, there is no pre-existing file in the target directory.