Gli articoli sono molto interessanti, anche se belli tosti per me...<div>Comunque facendo delle prove ho capito che</div><div>le namedtuple introdotte nell'articolo, un po' datato in realtà, fanno in pratica quello che io ottengo da csv.DictReader e csv.DictWriter.</div>
<div>Con poche righe di codice di ha un esempio di lettura e scrittura di un file csv.</div><div><br></div><div><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  import csv</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br></blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  path = './'</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  sep = '\t'</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  f_input = open(path+'dettaglio_2.csv','rb')</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  f_output = open(path+'dettaglio_2_out.csv','wb')</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  </blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  csvreader = csv.DictReader(f_input,delimiter=sep)</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  csvwriter = csv.DictWriter(f_output, delimiter=sep, fieldnames=csvreader.fieldnames)</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">  for row in csvreader:</blockquote>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">    csvwriter.writerow(row)</blockquote>
<div><br></div></blockquote><div><br></div>Diciamo che questa parte l'ho già affrontata e funziona,</div><div>però mi sa che devo fare un passo indietro per progettare bene la struttura di un tracciato record tramite un database, mi sembra inevitabile.</div>
<div><div><br></div><div>Creare un database per es. in sqlite3 con le seguenti tabelle:</div><div><br></div><div>tab_db(codice,nome,descrizione,data,separatore)</div><div>tab_sequenza(codice_db,codice,nome,min,max,posizione,ordine)</div>
<div>tab_gruppo(codice_sequenza,codice,nome,descrizione,note)</div><div>tab_campo(codice_db,codice,nome,descrizione)</div><div>tab_tipo(codice,nome,descrizione,formattazione,allineamento,decimali,sep_decimali)</div><div>tab_tracciato(<span class="Apple-tab-span" style="white-space:pre">     </span>codice_db,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                      </span>codice_sequenza,</div><div><span class="Apple-tab-span" style="white-space:pre">                     </span>codice_gruppo,</div><div><span class="Apple-tab-span" style="white-space:pre">                       </span>codice_campo,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                      </span>codice_tipo,</div><div><span class="Apple-tab-span" style="white-space:pre">                 </span>pos_da,</div><div><span class="Apple-tab-span" style="white-space:pre">                      </span>pos_a,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                      </span>lunghezza,</div><div><span class="Apple-tab-span" style="white-space:pre">                   </span>valore,</div><div><span class="Apple-tab-span" style="white-space:pre">                      </span>obbligatorio,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                      </span>vuoto,</div><div><span class="Apple-tab-span" style="white-space:pre">                       </span>visibile,</div><div><span class="Apple-tab-span" style="white-space:pre">                    </span>bloccato</div>
<div><span class="Apple-tab-span" style="white-space:pre">                      </span>)</div></div><div><br></div><div>Ok, ci aggiorniamo...<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ciao,<br>ti dico subito che non lavoro su tale gestione di record, ma leggendo il tuo post mi è venuto in mente una serie di articoli scritti da Michele Simionato su stacktrace che più o meno gestiva il tuo stesso tipo di problema.<br>


Gli articoli sono questi:<br>1: <a href="http://stacktrace.it/2008/05/05/gestione-dei-record-python-1/" target="_blank">http://stacktrace.it/2008/05/05/gestione-dei-record-python-1/</a><br>2: <a href="http://stacktrace.it/2008/05/28/gestione-dei-record-python2/" target="_blank">http://stacktrace.it/2008/05/28/gestione-dei-record-python2/</a><br>


3: <a href="http://stacktrace.it/2008/06/10/gestione-dei-record-python3/" target="_blank">http://stacktrace.it/2008/06/10/gestione-dei-record-python3/</a><br><br>Spero che possa essere di tuo interesse e che affronti il tuo stesso problema se ho ben capito.<br>


Ciao fabrizio<br>
<br>_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@lists.python.it">Python@lists.python.it</a><br>
<a href="http://lists.python.it/mailman/listinfo/python" target="_blank">http://lists.python.it/mailman/listinfo/python</a><br>
<br></blockquote></div><br></div>