<?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 Extract file name from data table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extract-file-name-from-data-table/m-p/315310#M56746</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to open data tables where the file names are being extracted from my main table and after opening the data table, it will merge it into one data table. Also, col2 have the same values inside dt.&lt;/P&gt;&lt;P&gt;It should look like this:&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;C:\Desktop\Name_Ana_Gender_Female.jmp&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;C:\Desktop\Name_Grace_Gender_Female.jmp&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this code but it only opens one data table&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data Table( "sample_table" );

col_name=associative array(column(dt, "name" ) &amp;lt;&amp;lt;get values) &amp;lt;&amp;lt;get keys;
col_gender=associative array(column(dt, "gender" ) &amp;lt;&amp;lt;get values) &amp;lt;&amp;lt;get keys;

file_list = N Items( col_name );
file_path = "C:\Desktop";
For( i = 1, i &amp;lt; file_list, i++,
dt1 = Open( file_path || "Name_" || char(col_name[i]) || " _Gender_" || char(col_gender[1]) || ".jmp",
//merge the two opened table
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:19:49 GMT</pubDate>
    <dc:creator>UserID16644</dc:creator>
    <dc:date>2023-06-10T23:19:49Z</dc:date>
    <item>
      <title>Extract file name from data table</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-file-name-from-data-table/m-p/315310#M56746</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to open data tables where the file names are being extracted from my main table and after opening the data table, it will merge it into one data table. Also, col2 have the same values inside dt.&lt;/P&gt;&lt;P&gt;It should look like this:&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;C:\Desktop\Name_Ana_Gender_Female.jmp&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;C:\Desktop\Name_Grace_Gender_Female.jmp&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this code but it only opens one data table&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data Table( "sample_table" );

col_name=associative array(column(dt, "name" ) &amp;lt;&amp;lt;get values) &amp;lt;&amp;lt;get keys;
col_gender=associative array(column(dt, "gender" ) &amp;lt;&amp;lt;get values) &amp;lt;&amp;lt;get keys;

file_list = N Items( col_name );
file_path = "C:\Desktop";
For( i = 1, i &amp;lt; file_list, i++,
dt1 = Open( file_path || "Name_" || char(col_name[i]) || " _Gender_" || char(col_gender[1]) || ".jmp",
//merge the two opened table
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:19:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-file-name-from-data-table/m-p/315310#M56746</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2023-06-10T23:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extract file name from data table</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-file-name-from-data-table/m-p/315410#M56749</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Please take the time to go through the Discovering JMP and Using JMP documentation.&amp;nbsp; They will help you learn about the fundamental features of JMP.&amp;nbsp; Then, you will be able to use those features and then let JMP provide you with the JSL to create the scripts.&lt;/LI&gt;
&lt;LI&gt;There are several previous Discussion Tracks on the topic of reading in multiple data tables and then putting them together.&amp;nbsp; Please start searching them.&amp;nbsp; You will be able to solve your problems much faster.&lt;/LI&gt;
&lt;LI&gt;Here is a possible solution to your scripting needs.&amp;nbsp; It is untested.
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data Table( "sample_table" );

col_name = dt:names &amp;lt;&amp;lt; get values;
col_gender = dt:gender &amp;lt;&amp;lt; get values;

file_list = N Items( col_name );
file_path = "C:\Desktop\";

dtFinal = New Table( "Final Table" );

For( i = 1, i &amp;lt;= file_list, i++,
	dt1 = Open( file_path || "Name_" || Char( col_name[i] ) || " _Gender_" || Char( col_gender[1] ) || ".jmp" );
	dtFinal &amp;lt;&amp;lt; concatenate( dt1, append to first table( 1 ) );
	Close( dt1, nosave );
);&lt;/CODE&gt;&lt;/PRE&gt;
&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 01 Oct 2020 11:30:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-file-name-from-data-table/m-p/315410#M56749</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-10-01T11:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extract file name from data table</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-file-name-from-data-table/m-p/315411#M56750</link>
      <description>&lt;P&gt;If col_name only contains one item then you would expect your code to open only one table.&amp;nbsp; So why not start by looking at the contents of that list (use the show function).&amp;nbsp; How many items does it contain?&amp;nbsp; Next look at your loop - is it really looping over each item in the list?&amp;nbsp; Perhaps you need "&amp;lt;=" instead of "&amp;lt;".&amp;nbsp; I would also suggest that&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. you use meaningful names.&amp;nbsp; I would expect file_list to be a list of files and col_name to be the name of a column.&lt;/P&gt;
&lt;P&gt;2. don't put tons of logic into a single line, it's not clever - it&amp;nbsp; just makes it impossible to debug.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 11:39:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-file-name-from-data-table/m-p/315411#M56750</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2020-10-01T11:39:13Z</dc:date>
    </item>
  </channel>
</rss>

