Buongiorno a tutti,<br>è sicuramente una cosa banale ma sto sbattendo la testa sul seguente problema:<br><br>* dal nostro gestionale recupero un file CSV con lettere accentate, apostrofi e quant&#39;altro.<br>* devo importare il tutto in un file sqlite<br>

<br>Utilizzo il seguente codice (è una prova quindi non badate alle finezze):<br><br><div style="margin-left: 40px;"><i>import sqlite3<br>import os<br>import csv<br><br>con=sqlite3.connect(&#39;dbe.sqlite&#39;)<br>cur=con.cursor()<br>

<br>try:<br>    cur.execute(&#39;DROP TABLE cqrep000f&#39;)<br>except:<br>    pass<br><br>cur.execute(&#39;&#39;&#39;<br>        CREATE  TABLE &quot;cqrep000f&quot; (<br>            # segue una cinquantina di campi<br>            )<br>

    &#39;&#39;&#39;)<br>con.commit()<br><br>f = open(&#39;cqrep.csv&#39;)<br><br>csv_reader = csv.reader(f, delimiter=&#39;;&#39;, quotechar = &#39;&quot;&#39;)<br><br>for row in csv_reader:<br>    l=len(row)<br>    for i in range(l):<br>

        row[i]=unicode(row[i])<br><br>    cur.execute(&#39;INSERT INTO cqrep000f VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)&#39;, row)<br>

    con.commit()<br><br>cur.close()<br>con.close(</i>)<br><br></div>Tutto funziona finchè non incontra lettere con accenti, apostrofi o cose strane.<br>L&#39;errore che mi restituisce è il seguente:<br><br><div style="margin-left: 40px;">

<i>&quot;row[i]=unicode(row[i])<br>UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0xe0 in position 4: ordinal not in range(128)&quot;<br></i></div><br>Come posso ovviare il problema?<br>Grazie per gli aiuti.<br>