<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JMP 16: Script to open most recent .csv file in a folder. in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605135#M80769</link>
    <description>&lt;P&gt;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.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2023 16:33:19 GMT</pubDate>
    <dc:creator>WoHNY</dc:creator>
    <dc:date>2023-06-08T16:33:19Z</dc:date>
    <item>
      <title>JMP 16: Script to open most recent .csv file in a folder.</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605135#M80769</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:33:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605135#M80769</guid>
      <dc:creator>WoHNY</dc:creator>
      <dc:date>2023-06-08T16:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 16: Script to open most recent .csv file in a folder.</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605264#M80776</link>
      <description>&lt;P&gt;Did you search Functions in Help &amp;gt; Scripting Index and examine the File group of functions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="file.PNG" style="width: 958px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/50476i68B9DA306128860A/image-size/large?v=v2&amp;amp;px=999" role="button" title="file.PNG" alt="file.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could base a script on the Creation Date() or the Last Modification Date() functions.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 15:23:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605264#M80776</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2023-02-24T15:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 16: Script to open most recent .csv file in a folder.</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605313#M80777</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 16:54:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605313#M80777</guid>
      <dc:creator>WoHNY</dc:creator>
      <dc:date>2023-02-24T16:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 16: Script to open most recent .csv file in a folder.</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605315#M80779</link>
      <description>&lt;P&gt;You can match the file name with the Contains() function if you want to ignore the time stamp.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 17:57:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605315#M80779</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2023-02-24T17:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: JMP 16: Script to open most recent .csv file in a folder.</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605372#M80781</link>
      <description>&lt;P&gt;I just happen to have had this need in the past, and luckily saved a script just in case...&lt;/P&gt;
&lt;P&gt;You'll need to change the strings on line 2 and 3.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Select where( :ext != searchext );
dt &amp;lt;&amp;lt; Delete Rows;

newest = Col Min( :Date );
newfile = searchfolder || "/" || :Name[dt &amp;lt;&amp;lt; Get Rows Where( :Date == newest )][1];
Close( dt, no save );
Open( newfile );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Feb 2023 19:21:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-16-Script-to-open-most-recent-csv-file-in-a-folder/m-p/605372#M80781</guid>
      <dc:creator>Jed_Campbell</dc:creator>
      <dc:date>2023-02-24T19:21:58Z</dc:date>
    </item>
  </channel>
</rss>

