cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-34466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ENo%20se%20pueden%20eliminar%20columnas%20en%20un%20datatable%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34466%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EBuenos%20d%C3%ADas%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EActualmente%20estoy%20escribiendo%20un%20script%20para%20extraer%20datos%20de%20un%20archivo%20de%20Excel%20y%20formatear%20la%20tabla%20de%20datos.%3C%2FP%3E%3CP%3EUn%20ejemplo%20t%C3%ADpico%20se%20adjunta%20a%20este%20post.%3C%2FP%3E%3CP%3EMi%20preocupaci%C3%B3n%20es%20que%20no%20puedo%20eliminar%20las%20%C3%BAltimas%20columnas%20(6%C2%AA%20columna%20hasta%20el%20final).%20%C2%BFTienes%20alguna%20pista%20sobre%20cu%C3%A1l%20es%20el%20problema%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C2%A1Gracias%20de%20antemano%20por%20tu%20ayuda!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20No%20se%20pueden%20eliminar%20columnas%20en%20un%20datatable%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34469%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EProblema%20solucionado%2C%20gracias!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20No%20se%20pueden%20eliminar%20columnas%20en%20un%20datatable%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34468%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAl%20eliminar%20columnas%2C%20se%20cambian%20las%20dimensiones%20de%20la%20tabla%2C%20lo%20que%20puede%20hacer%20que%20falle%20un%20bucle%20de%20avance.%26nbsp%3BTrate%20de%20eliminar%20desde%20el%20final.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Current%20Data%20Table()%3B%0An%20%3D%20N%20Col(dt)%3B%0A%2F%2F%20Delete%20last%20six%20columns%20columns%2C%20starting%20from%20the%20end%0AFor(i%20%3D%20n%2C%20i%20%26gt%3B%20n%20-%206%2C%20i--%2C%0A%20%20%20%20dt%20%26lt%3B%26lt%3B%20delete%20columns(Column(i))%0A)%3B%0A%0A%2F%2F%20This%20should%20also%20work%3A%20delete%20very%20last%20column%20six%20times%0AFor(i%20%3D%201%2C%20i%20%26lt%3B%3D%206%2C%20i%2B%2B%2C%0A%20%20%20%20dt%20%26lt%3B%26lt%3B%20delete%20columns(Column(N%20Col(dt)))%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
j_bonnouvrier
Level III

Unable to delete columns in a datatable

Good morning,

 

I am currently writing a script in order to extract data from an Excel file and format the data table.

A typical exemple is enclosed to this post.

My concern is that I cannot delete the last columns (6th column to the end). Do you have any clue on what  the problem is?

 

Thanks in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Unable to delete columns in a datatable

Deleting columns changes the dimensions of the table which can cause a forward going loop to fail. Try to delete from the end.

 

dt = Current Data Table();
n = N Col(dt);
// Delete last six columns columns, starting from the end
For(i = n, i > n - 6, i--,
    dt << delete columns(Column(i))
);

// This should also work: delete very last column six times
For(i = 1, i <= 6, i++,
    dt << delete columns(Column(N Col(dt)))
);

View solution in original post

2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Unable to delete columns in a datatable

Deleting columns changes the dimensions of the table which can cause a forward going loop to fail. Try to delete from the end.

 

dt = Current Data Table();
n = N Col(dt);
// Delete last six columns columns, starting from the end
For(i = n, i > n - 6, i--,
    dt << delete columns(Column(i))
);

// This should also work: delete very last column six times
For(i = 1, i <= 6, i++,
    dt << delete columns(Column(N Col(dt)))
);
j_bonnouvrier
Level III

Re: Unable to delete columns in a datatable

Problem fixed, thanks!

Recommended Articles