<div dir="ltr">Ciao Marcello,<div>grazie della risposta, controlla pero con il tuo pythonista, l'output funziona ma ci deve essere un modo piu idiomatico di farlo. Questo da solo la prima colonna, piu il formato ciphercipher:ciphercipher</div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre"><br><div>has_modifica = lambda x: 'Modifica' in x</div><br><div>test = [['Settembre 2021'], ['01 Merc', '07:58', '12:36', 'milano', 'torino', ' ', '13:57', '17:33', 'roma', 'napoli'], ['02 Giov', '07:32', '12:55', 'Torino', 'palermo', ' ', '14:13', '18:43', 'como', 'genova'],</div><div>['04 Saba'],</div><div>['05 Dome'],</div><div>['06 Lune', '07:41', '14:57', 'genova', 'livorno', ' ', '13:50', '19:08', 'siracusa', 'messina'], </div><div>['22 Merc', 'Modifica', ' ', '05:09', '12:09', 'Torino', 'Torino'],</div><div>['29 Merc', 'Modifica']]</div><br><div>out = []</div><div>v = [ x[0:2] if has_modifica(x) else x for x in test]</div><br><div>def filter_out(k):</div><div> y = k.strip()</div><div> x = y.split(":")</div><div> if len(x) != 2:</div><div> return False</div><div> return x[0].isnumeric() and x[1].isnumeric()</div><br><div>for row in v:</div><div> z = list(filter(filter_out ,row[2:]))</div><div> c = []</div><div> if len(z) > 0:</div><div> c = [row[0], *z] </div><div> else:</div><div> c = [row[0]]</div><div> out.append(c)</div><br><div>for k in out:</div><div> print(k)</div></div></div><div><br></div><div><br></div><div>Saluti,</div><div>Giorgio</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno sab 16 ott 2021 alle ore 13:32 Marcello <<a href="mailto:marcello@linuxvil.it">marcello@linuxvil.it</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="IT"><div class="gmail-m_1962047548993454570WordSection1"><p class="MsoNormal" style="margin-left:35.4pt"><b><span style="font-size:11pt;font-family:Calibri,sans-serif">Da:</span></b><span style="font-size:11pt;font-family:Calibri,sans-serif"> Python <<a href="mailto:python-bounces@lists.python.it" target="_blank">python-bounces@lists.python.it</a>> <b>Per conto di </b>Giorgio Zoppi<br><b>Inviato:</b> sabato 16 ottobre 2021 09:34<br><br><u></u><u></u></span></p><p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p><div><div><p class="MsoNormal" style="margin-left:35.4pt">Ciao Marcello,<u></u><u></u></p><div><p class="MsoNormal" style="margin-left:35.4pt">addormentato non ho letto bene:)<u></u><u></u></p></div><div><p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p></div><div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span class="gmail-m_1962047548993454570gmail-im"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)"><u></u> <u></u></span></span></p><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">has_modifica = lambda x: 'Modifica' in x</span><u></u><u></u></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">test = [['Settembre 2021'], ['01 Merc', '07:58', '12:36', 'milano', 'torino', ' ', '13:57', '17:33', 'roma', 'napoli'], ['02 Giov', '07:32', '12:55', 'Torino', 'palermo', ' ', '14:13', '18:43', 'como', 'genova'], <u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">['04 Saba'], <u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">['05 Dome'],<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">['06 Lune', '07:41', '12:57', 'genova', 'livorno', ' ', '13:50', '19:08', 'siracusa', 'messina'], \<u></u><u></u></span></p></div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span class="gmail-m_1962047548993454570gmail-im"><u></u> <u></u></span></p><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">['22 Merc', 'Modifica', ' ', '05:09', '12:09', 'Torino', 'Torino'],\</span><u></u><u></u></p></div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span class="gmail-m_1962047548993454570gmail-im"><u></u> <u></u></span></p><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">['29 Merc', 'Modifica']]</span><u></u><u></u></p></div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black"><u></u> <u></u></span></p><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black">items = ['TORINO', 'ROMA','MILANO','NAPOLI','GENOVA','COMO','PALERMO','MESSINA','SIRACUSA','LIVORNO', ' ']<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black">out = []<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(80,0,80)">v = [ x[0:2] if has_modifica(x) else x for x in test]<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black">for row in v:<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black">z = list(filter(lambda x: x.upper() not in items ,row))<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black">out.append(z)<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black">for k in out:<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:black">print(k)<u></u><u></u></span></p></div><div><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Ciao Giorgio,<u></u><u></u></span></p><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">così come hai fatto funziona, ma il mio problema è che non ho un elenco di città (potenzialmente potrebbe essere anche un paese) quindi devo fare in modo che il campo sia corretto solo se comincia con 2 numeri tipo<u></u><u></u></span></p><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">if record[:2].isnumeric():<u></u><u></u></span></p><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p></div><div><p class="MsoNormal" style="line-height:14.25pt;background:rgb(255,255,254)"><span style="font-size:10.5pt;font-family:"Courier New";color:rgb(31,73,125)"><u></u> <u></u></span></p></div></div></div></div><div><div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div>_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@lists.python.it" target="_blank">Python@lists.python.it</a><br>
<a href="https://lists.python.it/mailman/listinfo/python" rel="noreferrer" target="_blank">https://lists.python.it/mailman/listinfo/python</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Life is a chess game - Anonymous.<br></div></div>