<?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 Re: merging files in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/merging-files/m-p/53388#M30222</link>
    <description>&lt;P&gt;A quick scan of your code......I assume that CName[i] is not being interpreted as a column in your &amp;lt;&amp;lt; Set Selected.&amp;nbsp; use a Column() function to insure it points to being a column reference.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Column(CName[i]) &amp;lt;&amp;lt; Set Selected( 1 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 19 Mar 2018 14:49:19 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-03-19T14:49:19Z</dc:date>
    <item>
      <title>merging files</title>
      <link>https://community.jmp.com/t5/Discussions/merging-files/m-p/53386#M30220</link>
      <description>&lt;P&gt;im trying to merge text files and turn them into excel files.&lt;/P&gt;
&lt;P&gt;i found to scripts one which merges files and a second which cleans it ( delets empty columns and such).&lt;/P&gt;
&lt;P&gt;when i combine the two scripts i get this message:&lt;/P&gt;
&lt;P&gt;"send expects scriptable object in access or evaluation of 'send' "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the script fails at: Set Selected()&lt;/P&gt;
&lt;P&gt;can someone please help me solve the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is how i combined the two:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here (1);
Clear Symbols();
//set up variables with starting values
filelist={}; //empty list
//launch dialog to get the file location
(
prefilepath = munger(Pick Directory( "Browse to the Directory of the .txt / .csv files " ),1,"/","");
filepath = Convert File Path( prefilepath, Windows );
prefilelist = Files In Directory( filepath );
n2=nitems(prefilelist);
//filter out any non-txt or csv files
For( i2 = 1, n2 &amp;gt;= i2, i2++,
file=(prefilelist[i2]);
// changed from item 2 to item -1
If( Item( -1, prefilelist[i2], "." ) == "txt" | Item( -1, prefilelist[i2], "." ) == "csv",
Insert Into( filelist,file),
show(file)
)
);
/*
//filter out any non-Excel files for the file list. Commented out
For( i2 = 1, n2 &amp;gt;= i2, i2++,
file=(prefilelist[i2]);
If( Item( -1, prefilelist[i2], "." ) == "xls" | Item( -1, prefilelist[i2], "." ) == "xlsx",
Insert Into( filelist,file),
show(file)
)
);
*/
nf=nitems(filelist); //number of items in the working list
cctable= New Table( "Combined data table ");//make an empty table
cctable&amp;lt;&amp;lt;New Column( "Source", Character, Nominal );
For( iii = 1 , iii &amp;lt;= nf, iii++, //this starts the first loop
filenow = ( filelist[iii] );
fileopen=(filepath||filenow);
dt=open(fileopen,private);
New Column( "Source", Character, Nominal );
:Source &amp;lt;&amp;lt; set each value( filenow );
//dt&amp;lt;&amp;lt;new column("Source", character, nominal)&amp;lt;&amp;lt;set each value(9999);
dt &amp;lt;&amp;lt; Run Formulas();
//add the current table to the bottom of the combined data table
cctable &amp;lt;&amp;lt; Concatenate( Data Table( dt ), Append to first table );
//don't use "Create Source Column" argument
Close( dt, NoSave );//after concatenating the table, close it and move on
);//end of the first for loop

(
//Select analytics file "DT_Import" and open
DT_Import = cctable;
DT_Import &amp;lt;&amp;lt; Minimize Window;

//Get data table name and set operating directory as opened file location
TableName = DT_Import &amp;lt;&amp;lt; Get Name();
Directory = prefilepath);
//Remove extraneous rows
Rows_to_delete = DT_Import &amp;lt;&amp;lt; Get rows where(Is Missing(:WLD Filename) &amp;gt; 0|
Contains(:WLD Filename, "----") &amp;gt; 0|
Contains(:WLD Filename,"Reprocess Started:")|
Contains(:WLD Filename,"Reprocess Completed:")|
Contains(:WLD Filename,"Comments:")
);
If(ANY(Rows_to_delete) == 1,
DT_Import &amp;lt;&amp;lt; Delete Rows(Rows_to_delete);
);
//Find locations of misaligned headers for cleanup
Row_Clip = DT_Import &amp;lt;&amp;lt; Get rows where(Contains(:WLD Filename, "WLD Filename") &amp;gt; 0);
//If cleanup needed, continue to concatenation of displaced headers
If(N Rows(Row_Clip) &amp;gt; 0,
//Add End Row to Row List
End_Row = N Rows(DT_Import);
Row_Clip_End = VConcat(Row_Clip,End_Row);
Total_Clips = N Rows(Row_Clip)+1;
//Create invisible repair table from initial rows
DT_Import &amp;lt;&amp;lt; Select Rows(Index(1, Row_Clip[1]));
DT_Wafer = DT_Import &amp;lt;&amp;lt; Subset( Selected Rows , Output Table Name(TableName||"_Repair"), invisible);
DT_Import &amp;lt;&amp;lt; Clear Select;
DT_Wafer &amp;lt;&amp;lt; select where(Contains(:WLD Filename, "WLD Filename") &amp;gt; 0);
DCheck = DT_Wafer &amp;lt;&amp;lt; Get selected rows;
If(ANY(DCheck) == 1,
DT_Wafer &amp;lt;&amp;lt; Delete Rows;
);
DT_Wafer &amp;lt;&amp;lt; Begin Data Update;
//Concatenation Loop
For (n=1, n &amp;lt; Total_Clips, n++,
DT_Import &amp;lt;&amp;lt; Select Rows(Index(Row_Clip[n], Row_Clip_End[n+1]));
DT_temp = DT_import &amp;lt;&amp;lt; Subset(Selected Rows, invisible, Output Table("Temp"));
DT_Import &amp;lt;&amp;lt; Clear Select;
For (i=1, i &amp;lt; N Cols()+1, i++,
col = Column(i);
col &amp;lt;&amp;lt; Set Name("Col"||Char(i));
);
For (j=1, j &amp;lt; N Cols()+1, j++,
col = Column(j);
col &amp;lt;&amp;lt; Set Name(col[1]);
);
DT_temp &amp;lt;&amp;lt; select rows (1);
DCheck = DT_temp &amp;lt;&amp;lt; Get selected rows;
If(ANY(DCheck) == 1,
DT_temp &amp;lt;&amp;lt; delete rows;
);
DT_temp &amp;lt;&amp;lt; select where(Contains(:WLD Filename, "WLD Filename") &amp;gt; 0);
DCheck = DT_temp &amp;lt;&amp;lt; Get selected rows;
If(ANY(DCheck) == 1,
DT_temp &amp;lt;&amp;lt; delete rows;
);
Data Table(TableName||"_Repair") &amp;lt;&amp;lt; Concatenate(Data Table("Temp"), invisible, Append to first table);
Close("Temp");
Cleanup_Processing=Round(100*(n+1)/(Total_Clips),1);
wait(0);
Completion_Monitor &amp;lt;&amp;lt; Bring Window to Front;
);
DT_Wafer &amp;lt;&amp;lt; End Data Update;
//Close(DT_Import);

//If no Cleanup needed
,DT_Wafer = DT_Import;
Cleanup_Processing=100;
);
//Remove any of the unnamed import artifact columns with no data
CName = DT_Wafer &amp;lt;&amp;lt; Get Column Names();
CCount = N Items(CName);
for(i=1,i&amp;lt;=CCount,i++,
CTest = Column(CName[i]);
If(Contains(CName[i],"Col") &amp;gt; 0 &amp;amp; Is Missing(CTest[1]),
CName[i]&amp;lt;&amp;lt;Set Selected(1));
);
DCheck = DT_Wafer &amp;lt;&amp;lt; Get selected columns;
If(Is Empty(DCheck) == 0,
DT_Wafer &amp;lt;&amp;lt; delete columns;
);
DT_Wafer &amp;lt;&amp;lt; Clear Select;
DT_Wafer &amp;lt;&amp;lt; Clear Column Selection;
//Set text export preferences
Preferences(Export Settings(Export Table Headers));
Preferences(Export Settings(End of Field(Tab)));
DT_Wafer &amp;lt;&amp;lt; Show Window(1);
(
DT_Wafer &amp;lt;&amp;lt; Save(Directory||TableName||"_attempt.csv", Text);
);
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;attached are the original scripts (i did not write them).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:49:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/merging-files/m-p/53386#M30220</guid>
      <dc:creator>walk545</dc:creator>
      <dc:date>2018-03-19T14:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: merging files</title>
      <link>https://community.jmp.com/t5/Discussions/merging-files/m-p/53388#M30222</link>
      <description>&lt;P&gt;A quick scan of your code......I assume that CName[i] is not being interpreted as a column in your &amp;lt;&amp;lt; Set Selected.&amp;nbsp; use a Column() function to insure it points to being a column reference.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Column(CName[i]) &amp;lt;&amp;lt; Set Selected( 1 );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:49:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/merging-files/m-p/53388#M30222</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-03-19T14:49:19Z</dc:date>
    </item>
  </channel>
</rss>

