Choose Language Hide Translation Bar
Highlighted
Martin91
Level I

Call table from open table list and insert colum by matching criteria

Hello,

I am handling a bunch of csv logfiles. I want to use following approach to insert a column in a table if the string of file name matches a key word.

1. Import Multiple Files

2. Create table list of open files

3. Remove items not containing the key word

4. Insert formula column in matching table

5. Copy these values to a existing table

 

I am struggling with 4. and 5. Any ideas what I am doing wrong in my script below?

 

Thanks for your support.

BR

Names Default To Here( 1 );

// Create list of open tables
openTables = {};
For( i = 1, i <= N Table(), i++,
	Insert Into( openTables, Data Table( i ) << getName )
);
Sort List Into( openTables );

Show( openTables );


// Delete files excluding BFS
For( i = N Items( openTables ), i > 0, i--, 
	
	If( !Contains( openTables[i], "BFS" ),
		Remove From( openTables, i )
	
	)
		
);

Show( openTables );


// Insert column in matching table
For( i = N Items( openTables ), i > 0, i--, 
	
	openTables[i] << New Column( "test", set each value( 3 ) )
			
);

 


 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Call table from open table list and insert colum by matching criteria

You need to indicate in your attempt to add the new column that your openTable[I] is a Data Table().  

Names Default To Here( 1 );

// Create list of open tables
openTables = {};
For( i = 1, i <= N Table(), i++,
	Insert Into( openTables, Data Table( i ) << getName )
);
Sort List Into( openTables );

Show( openTables );


// Delete files excluding BFS
For( i = N Items( openTables ), i > 0, i--, 
	
	If( !Contains( openTables[i], "BFS" ),
		Remove From( openTables, i )
	
	)
		
);

Show( openTables );


// Insert column in matching table
For( i = N Items( openTables ), i > 0, i--, 
	
	Data Table( openTables[i] ) << New Column( "test", set each value( 3 ) )
			
);
Jim

View solution in original post

1 REPLY 1
Highlighted
txnelson
Super User

Re: Call table from open table list and insert colum by matching criteria

You need to indicate in your attempt to add the new column that your openTable[I] is a Data Table().  

Names Default To Here( 1 );

// Create list of open tables
openTables = {};
For( i = 1, i <= N Table(), i++,
	Insert Into( openTables, Data Table( i ) << getName )
);
Sort List Into( openTables );

Show( openTables );


// Delete files excluding BFS
For( i = N Items( openTables ), i > 0, i--, 
	
	If( !Contains( openTables[i], "BFS" ),
		Remove From( openTables, i )
	
	)
		
);

Show( openTables );


// Insert column in matching table
For( i = N Items( openTables ), i > 0, i--, 
	
	Data Table( openTables[i] ) << New Column( "test", set each value( 3 ) )
			
);
Jim

View solution in original post

Article Labels

    There are no labels assigned to this post.