cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-271473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECome%20trovare%20la%20riga%20e%20la%20colonna%20(cella)%20che%20corrisponde%20a%20un%20valore%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-271473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHo%20tabelle%20che%20vengono%20generate%20e%20il%20formato%20%C3%A8%20diverso%20di%20volta%20in%20volta%20e%20interrompe%20il%20mio%20script.Le%20tabelle%20sono%20enormi%20e%20quindi%20il%20modo%20in%20cui%20gestisco%20i%20miei%20loop%20%C3%A8%20importare%20le%20prime%20100%20righe%20e%205%20colonne%2C%20per%20velocit%C3%A0.Quindi%20cerco%20una%20parola%20chiave%20in%20una%20colonna%20particolare%20per%20aiutarmi%20a%20sapere%20dove%20iniziano%20i%20dati%20reali.Chiudo%20il%20file%20e%20poi%20lo%20riapro%20con%20quella%20variabile%20che%20identifica%20l'intestazione%20della%20colonna%20e%20l'inizio%20dei%20dati.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETuttavia%2C%20come%20accennato%20in%20precedenza%2C%20circa%20l'1%25%20dei%20file%20%C3%A8%20incasinato%20e%20ha%20colonne%20extra%20all'inizio%20e%20talvolta%20qualche%20centinaio%20di%20righe%20casuali%2C%20quindi%20il%20mio%20script%20fa%20inciampare.Stavo%20pensando%20che%20se%20riesco%20a%20cercare%20la%20mia%20parola%20chiave%20nell'intera%20tabella%20abbreviata%2C%20posso%20aggirare%20il%20problema%2C%20ma%20non%20sono%20sicuro%20di%20come%20cercare%20pi%C3%B9%20colonne%20contemporaneamente%2C%20soprattutto%20quando%20cambiano%20i%20nomi%20delle%20colonne.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEcco%20il%20metodo%20che%20utilizzo%20attualmente%20per%20identificare%20la%20mia%20riga%2C%20cercando%20in%20una%20colonna%20particolare.Come%20posso%20aprirlo%20per%20cercare%20nelle%20colonne%201-10%20o%20anche%20nell'intera%20tabella%3F%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%2F%2Fnr1%20becomes%20the%20column%20headers%20and%20nr2%20becomes%20the%20first%20row%20of%20data%20when%20i%20reopen%20the%20full%20table.%3CBR%20%2F%3Enr1%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20rows%20where(%20%3ACol1%20%3D%3D%20%22customparameter%22%20)%3B%0Anr2%20%3D%20nr1%20%2B%201%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-271473%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAccesso%20ai%20dati%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPersonalizzazione%20di%20massa%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-271602%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20Come%20trovare%20la%20riga%20e%20la%20colonna%20(cella)%20che%20corrisponde%20a%20un%20valore%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-271602%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2687%22%20target%3D%22_blank%22%3E%40txnelson%3C%2FA%3E%20%2C%20Grazie%20per%20la%20risposta.I%20nomi%20delle%20colonne%20non%20sono%20indicativi%20del%20contenuto%2C%20sono%20tabelle%20davvero%20assurde.Questo%20%C3%A8%20il%20motivo%20per%20cui%20devo%20individuare%20dove%20iniziano%20i%20dati%20effettivi%2C%20chiudere%20la%20tabella%20e%20quindi%20reimportare%20la%20tabella%20completa%20con%20la%20riga%20corretta%20che%20identifica%20le%20colonne.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIl%20tuo%20commento%20per%C3%B2%20mi%20ha%20fatto%20capire%20che%20posso%20prendere%20tutti%20i%20nomi%20delle%20colonne%2C%20quindi%20eseguire%20un%20ciclo%20su%20ciascuna%20colonna%20e%20se%20trova%20il%20valore%20della%20cella%20corrispondente%2C%20assegnare%20il%20valore%20della%20riga%20alla%20mia%20variabile%20ed%20uscire%20dal%20ciclo.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-271520%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20Come%20trovare%20la%20riga%20e%20la%20colonna%20(cella)%20che%20corrisponde%20a%20un%20valore%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-271520%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%C3%88%20possibile%20fare%20riferimento%20alle%20colonne%20in%20una%20tabella%20dati%20tramite%20numero%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%26lt%3B%26lt%3B%20select%20where(%20column(dt%2C%203%20)%20%3D%3D%20%22Top%22%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eoppure%20puoi%20facilmente%20recuperare%20i%20nomi%20delle%20colonne%20in%20una%20tabella%20dati%20e%20fare%20riferimento%20a%20tali%20nomi%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EcolNames%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names%3B%0Adt%20%26lt%3B%26lt%3B%20select%20where(%20column(%20dt%2C%20colNames%5B3%5D%20%3D%3D%20%22Top%22%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Equindi%20una%20volta%20estratto%20il%20campione%2C%20puoi%20trovare%20i%20nomi%20delle%20colonne%20o%20semplicemente%20cercare%20per%20numero%20di%20colonna.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
SamKing
Level III

How to find row and column (cell) that matches a value

I have tables that are generated and the format is different from time to time and it breaks my script.  The tables are massive and so the way i handle my loops is that i import the first 100 rows and 5 columns, for speed.  Then i search a particular column for a keyword to help me know where which row the real data starts.  I close the file then reopen with that variable identifying the column header and data start.

 

However, as mentioned above about 1% of the files are dorked up and have extra columns at the beginning and sometimes a few hundred random rows so it trips up my script.  I was thinking that if I can search the whole abreviated table for my keyword then i can get around it but i'm unsure how to search multiple columns at once, especially when the column names change.

 

Here is the method that I currently use to identify my row, looking in a particular column.  How do i open this up to search columns 1-10 or even the whole table?

//nr1 becomes the column headers and nr2 becomes the first row of data when i reopen the full table.
nr1 = dt << get rows where( :Col1 == "customparameter" ); nr2 = nr1 + 1;
2 REPLIES 2
txnelson
Super User

Re: How to find row and column (cell) that matches a value

You can refer to columns in a data table by number

dt << select where( column(dt, 3 ) == "Top" );

or you can easily retrieve the column names in a data table, and refer to those names

colNames = dt << get column names;
dt << select where( column( dt, colNames[3] == "Top" );

so once you have extracted you sample, you can find the names of the columns or just search by column number.

Jim
SamKing
Level III

Re: How to find row and column (cell) that matches a value

@txnelson, thanks for the response.  The column names are not indicative of the content, they are really screwy tables.  That is why i have to locate where the actual data starts, close the table then re-import the full table with the correct row identifying the columns.

 

Your comment though made me realize that i can grab all the column names then do a loop through each column and if it finds the matching cell value then assign the row value to my variable and exit the loop.

Recommended Articles