cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-847921%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELes%20fonctions%20Rename%20File()%20et%20Copy%20File()%20renvoient%20toutes%20deux%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-847921%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESalut%2C%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EJ'ai%20besoin%20d'enregistrer%20une%20petite%20table%20de%20donn%C3%A9es%20au%20format%20CSV%2C%20mais%20avec%20une%20extension%20de%20fichier%20diff%C3%A9rente%20(*.blkl%20plut%C3%B4t%20que%20*.csv).%20La%20fonction%20Enregistrer%20sous()%20ne%20semble%20pas%20permettre%20une%20telle%20option.%20Au%20lieu%20d'enregistrer%20le%20fichier%20sous%20le%20nom%20souhait%C3%A9%2C%20je%20l'enregistre%20sous%20*.blkl.csv%2C%20puis%20j'essaie%20de%20le%20renommer%20directement%20ou%20d'effectuer%20une%20op%C3%A9ration%20de%20copier-supprimer%20pour%20obtenir%20le%20fichier%20de%20sortie%20souhait%C3%A9.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EMon%20script%20enregistre%20le%20fichier%2C%20mais%20les%20fonctions%20Rename%20File()%20et%20Copy%20File()%20renvoient%20toutes%20deux%200%2C%20indiquant%20que%20l'op%C3%A9ration%20a%20%C3%A9chou%C3%A9%20sans%20autre%20information.%20Comment%20puis-je%20d%C3%A9boguer%20les%20op%C3%A9rations%20de%20fichier%20ayant%20%C3%A9chou%C3%A9%26nbsp%3B%3F%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EJMP%2014.3.0%20(64%20bits)%3CBR%20%2F%3E%20Windows%2011%20Entreprise%20(64%20bits)%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EMerci%20d'avance!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-847921%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EWindows%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-847932%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Rename%20File()%20et%20Copy%20File()%20renvoient%20tous%20deux%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-847932%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EComment%20faites-vous%26nbsp%3B%3F%20Pour%20moi%2C%20%C3%A7a%20fonctionne%20bien%20(avec%20JMP18).%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%20%0A%0Adt%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20Save(%22%24TEMP%2Fbigclass.csv%22)%3B%0A%0AShow(File%20Exists(%22%24TEMP%2Fbigclass.csv%22)%2C%20File%20Exists(%22%24TEMP%2Fbigclass.blkl%22))%3B%0ARename%20File(%22%24TEMP%2Fbigclass.csv%22%2C%20%22bigclass.blkl%22)%3B%0AShow(File%20Exists(%22%24TEMP%2Fbigclass.csv%22)%2C%20File%20Exists(%22%24TEMP%2Fbigclass.blkl%22))%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-847934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Rename%20File()%20et%20Copy%20File()%20renvoient%20tous%20deux%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-847934%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EJ'ai%20v%C3%A9rifi%C3%A9%20que%20le%20code%20de%20Jarmo%20fonctionne%20dans%20JMP%2014%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-847964%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Rename%20File()%20et%20Copy%20File()%20renvoient%20tous%20deux%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-847964%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EJ'ai%20trouv%C3%A9%20le%20probl%C3%A8me.%20Les%20fonctions%20Rename%20File()%20et%20Copy%20File()%20%C3%A9chouent%20si%20le%20fichier%20existe%2C%20elles%20ne%20sont%20donc%20pas%20adapt%C3%A9es%20ind%C3%A9pendamment%20aux%20op%C3%A9rations%20d'%C3%A9crasement.%20J'ai%20ajout%C3%A9%20une%20v%C3%A9rification%20pr%C3%A9alable%20%C3%A0%20la%20suppression%20et%20tout%20fonctionne%20correctement%20maintenant.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EPour%20r%C3%A9f%C3%A9rence%20future%2C%20les%20fonctions%20de%20la%20biblioth%C3%A8que%20jsl%20signalent-elles%20ce%20type%20d'informations%20de%20d%C3%A9bogage%20n'importe%20o%C3%B9%20ou%20s'agit-il%20simplement%20d'un%20statut%20de%20r%C3%A9ussite%2F%C3%A9chec%26nbsp%3B%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-847989%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Rename%20File()%20et%20Copy%20File()%20renvoient%20tous%20deux%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-847989%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ECertaines%20fonctions%20peuvent%20vous%20fournir%20des%20informations%20suppl%C3%A9mentaires%2C%20par%20exemple%20si%20vous%20essayez%20d'%C3%A9craser%20une%20table%20de%20donn%C3%A9es%20d%C3%A9j%C3%A0%20ouverte.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%20%0A%0Adt%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0Adt%20%26lt%3B%26lt%3B%20Save(%22%24TEMP%2Fbigclass_test.jmp%22)%3B%0A%0Adt1%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class%20Families.jmp%22)%3B%0A%0Adt1%20%26lt%3B%26lt%3B%20Save(%22%24TEMP%2Fbigclass_test.jmp%22)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_0-1742020880612.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1742020880612.png%22%20style%3D%22width%3A%20173px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F73892iED12F3E6DB0F2B8B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jthi_0-1742020880612.png%22%20alt%3D%22jthi_0-1742020880612.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eet%20vous%20obtenez%20ceci%20pour%20enregistrer%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EThis%20file%20could%20not%20be%20saved%20with%20the%20given%20name.%0A%0AUnable%20to%20save%20file.%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
TheSource
Level II

Rename File() and Copy File() both return 0

Hi,

 

I have a need to save a small data table as a csv but with an alternate file extension (*.blkl rather than *.csv). The Save As() function doesn't seem to allow for such a provision as near as I can tell so instead of saving the file with my desired filename I save it as *.blkl.csv and then attempt to either directly rename that file to the desired name or perform a copy+delete sequence to get the desired output file.

 

My script will happily save the file but both the Rename File() and Copy File() functions both return 0 indicating that the operation failed with no other information given. How can I go about debugging the failed file operations?

 

JMP 14.3.0 (64 bit)
Windows 11 Enterprise (64 bit)

 

Thanks in advance!

4 REPLIES 4
jthi
Super User

Re: Rename File() and Copy File() both return 0

How are you trying to do it? For me this works fine (using JMP18)

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << Save("$TEMP/bigclass.csv");

Show(File Exists("$TEMP/bigclass.csv"), File Exists("$TEMP/bigclass.blkl"));
Rename File("$TEMP/bigclass.csv", "bigclass.blkl");
Show(File Exists("$TEMP/bigclass.csv"), File Exists("$TEMP/bigclass.blkl"));
-Jarmo
txnelson
Super User

Re: Rename File() and Copy File() both return 0

I verified that Jarmo's code works in JMP 14

Jim
TheSource
Level II

Re: Rename File() and Copy File() both return 0

I found the issue. Both Rename File() and Copy File() will fail if the file exists so they aren't independently suitable for overwrite operations. I've added a delete-pre-check and it's all running smoothly now.

 

For future reference, do jsl library functions report this sort of debug information anywhere or is it just pass/fail status?

jthi
Super User

Re: Rename File() and Copy File() both return 0

Some functions might give you some more feedback. For example if you try to overwrite data table which is already open

Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Save("$TEMP/bigclass_test.jmp");

dt1 = Open("$SAMPLE_DATA/Big Class Families.jmp");

dt1 << Save("$TEMP/bigclass_test.jmp");

jthi_0-1742020880612.png

and you get this to log

This file could not be saved with the given name.

Unable to save file.
-Jarmo

Recommended Articles