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-605135%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EJMP%2016%20%3A%20Script%20pour%20ouvrir%20le%20fichier%20.csv%20le%20plus%20r%C3%A9cent%20dans%20un%20dossier.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-605135%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EJ'ai%20utilis%C3%A9%20le%20chemin%20%3D%20Pick%20File()%3B%20commande%20pour%20s%C3%A9lectionner%20manuellement%20le%20fichier%20%C3%A0%20importer%20dans%20une%20table%20de%20donn%C3%A9es.%20Pouvez-vous%20%C3%A9crire%20une%20commande%20pour%20importer%20le%20fichier%20.csv%20le%20plus%20r%C3%A9cent%20d'un%20dossier%20dans%20une%20table%20de%20donn%C3%A9es%26nbsp%3B%3F%20Il%20n'y%20a%20qu'une%20seule%20feuille%20de%20calcul%20dans%20ces%20fichiers.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-605135%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3ETableau%20de%20donn%C3%A9es%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EScript%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-605264%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20JMP%2016%26nbsp%3B%3A%20Script%20pour%20ouvrir%20le%20fichier%20.csv%20le%20plus%20r%C3%A9cent%20dans%20un%20dossier.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-605264%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAvez-vous%20recherch%C3%A9%20Fonctions%20dans%20Aide%20%26gt%3B%20Index%20des%20scripts%20et%20examin%C3%A9%20le%20groupe%20de%20fonctions%20Fichier%20%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22file.PNG%22%20style%3D%22width%3A%20958px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F50476i68B9DA306128860A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22file.PNG%22%20alt%3D%22file.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EVous%20pouvez%20baser%20un%20script%20sur%20les%20fonctions%20Creation%20Date()%20ou%20Last%20Modification%20Date().%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-605313%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20JMP%2016%26nbsp%3B%3A%20Script%20pour%20ouvrir%20le%20fichier%20.csv%20le%20plus%20r%C3%A9cent%20dans%20un%20dossier.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-605313%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMarc%20%3A%20Merci%20pour%20la%20r%C3%A9ponse.%20Je%20n'%C3%A9tais%20pas%20au%20courant%20de%20l'index%20de%20script%20sous%20l'aide%2C%20donc%20c'est%20une%20grande%20aide%20pour%20l'avenir.%20Je%20faisais%20r%C3%A9f%C3%A9rence%20%C3%A0%20une%20version%20pdf%20d'un%20guide%20de%20script%20JMP15%20qui%20n'est%20pas%20convivial%20pour%20la%20recherche.%20Un%20probl%C3%A8me%20que%20j'ai%20avec%20le%20nom%20de%20fichier%20est%20qu'il%20inclut%20l'horodatage%20%C3%A0%20la%20fin%20du%20nom%2C%20il%20est%20donc%20dynamique.%20Le%20format%20est%20NomFichier_AAAAMMJJHHMM.csv.%20Je%20vais%20m'en%20tenir%20%C3%A0%20PickFile%20pour%20l'instant%20et%20exp%C3%A9rimenter%20avec%20la%20fonction%20LastModificationDate.%20Merci%20encore.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-605315%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20JMP%2016%26nbsp%3B%3A%20Script%20pour%20ouvrir%20le%20fichier%20.csv%20le%20plus%20r%C3%A9cent%20dans%20un%20dossier.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-605315%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVous%20pouvez%20faire%20correspondre%20le%20nom%20du%20fichier%20avec%20la%20fonction%20Contient()%20si%20vous%20souhaitez%20ignorer%20l'horodatage.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-605372%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20JMP%2016%26nbsp%3B%3A%20Script%20pour%20ouvrir%20le%20fichier%20.csv%20le%20plus%20r%C3%A9cent%20dans%20un%20dossier.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-605372%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIl%20se%20trouve%20que%20j'ai%20eu%20ce%20besoin%20dans%20le%20pass%C3%A9%20et%2C%20heureusement%2C%20j'ai%20enregistr%C3%A9%20un%20script%20au%20cas%20o%C3%B9...%3C%2FP%3E%0A%3CP%3EVous%20devrez%20changer%20les%20cha%C3%AEnes%20sur%20les%20lignes%202%20et%203.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Asearchext%20%3D%20%22jmp%22%3B%20%2F%2Fextension%20to%20look%20for%0Asearchfolder%20%3D%20%22%24DESKTOP%22%3B%20%2F%2Fplace%20to%20search%0A%0AlstExtensions%20%3D%20%7B%7D%3B%0AlstDates%20%3D%20%7B%7D%3B%0AlstFiles%20%3D%20Files%20In%20Directory(%20searchfolder%20)%3B%0AFor%20Each(%20%7Bi%2C%20j%7D%2C%20lstFiles%2C%0A%20lstExtensions%5Bj%5D%20%3D%20Char(%20Right(%20i%2C%203%20)%20)%3B%0A%20lstDates%5Bj%5D%20%3D%20As%20Date(%20Creation%20Date(%20searchfolder%20%7C%7C%20%22%2F%22%20%7C%7C%20Char(%20i%20)%20)%20)%3B%0A)%3B%0Adt%20%3D%20New%20Table(%20%22Files%22%2C%0A%20New%20Column(%20%22Name%22%2C%20character%2C%20set%20values(%20lstFiles%20)%20)%2C%0A%20New%20Column(%20%22ext%22%2C%20character%2C%20set%20values(%20lstExtensions%20)%20)%2C%0A%20New%20Column(%20%22Date%22%2C%20numeric%2C%20set%20values(%20Matrix(%20lstDates%20)%20)%20)%0A)%3B%0A%0Adt%20%26lt%3B%26lt%3B%20Select%20where(%20%3Aext%20!%3D%20searchext%20)%3B%0Adt%20%26lt%3B%26lt%3B%20Delete%20Rows%3B%0A%0Anewest%20%3D%20Col%20Min(%20%3ADate%20)%3B%0Anewfile%20%3D%20searchfolder%20%7C%7C%20%22%2F%22%20%7C%7C%20%3AName%5Bdt%20%26lt%3B%26lt%3B%20Get%20Rows%20Where(%20%3ADate%20%3D%3D%20newest%20)%5D%5B1%5D%3B%0AClose(%20dt%2C%20no%20save%20)%3B%0AOpen(%20newfile%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
WoHNY
Level IV

JMP 16: Script to open most recent .csv file in a folder.

I have been using the path = Pick File(); command to manually select the file to import into a data table. Can you script a command to import the most recent .csv file in a folder to a data table? There is only one worksheet in these files.

4 REPLIES 4

Re: JMP 16: Script to open most recent .csv file in a folder.

Did you search Functions in Help > Scripting Index and examine the File group of functions?

 

 

file.PNG

 

You could base a script on the Creation Date() or the Last Modification Date() functions.

WoHNY
Level IV

Re: JMP 16: Script to open most recent .csv file in a folder.

Mark: Thank you for the response. I wasn't aware of the Scripting index under help so that is big help going forward. I was referencing a pdf version of a JMP15 Scripting Guide that is not search friendly. One issue I have with the file name is that it includes the time stamp at the end of the name, so it is dynamic. The format is FileName_YYYYMMDDHHMM.csv. I will stick with PickFile for now and experiment with the LastModificationDate function. Thanks again.

Re: JMP 16: Script to open most recent .csv file in a folder.

You can match the file name with the Contains() function if you want to ignore the time stamp.

Re: JMP 16: Script to open most recent .csv file in a folder.

I just happen to have had this need in the past, and luckily saved a script just in case...

You'll need to change the strings on line 2 and 3.

Names Default To Here( 1 );
searchext = "jmp"; //extension to look for
searchfolder = "$DESKTOP"; //place to search

lstExtensions = {};
lstDates = {};
lstFiles = Files In Directory( searchfolder );
For Each( {i, j}, lstFiles,
	lstExtensions[j] = Char( Right( i, 3 ) );
	lstDates[j] = As Date( Creation Date( searchfolder || "/" || Char( i ) ) );
);
dt = New Table( "Files",
	New Column( "Name", character, set values( lstFiles ) ),
	New Column( "ext", character, set values( lstExtensions ) ),
	New Column( "Date", numeric, set values( Matrix( lstDates ) ) )
);

dt << Select where( :ext != searchext );
dt << Delete Rows;

newest = Col Min( :Date );
newfile = searchfolder || "/" || :Name[dt << Get Rows Where( :Date == newest )][1];
Close( dt, no save );
Open( newfile );

Recommended Articles