<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Devo però avvisare che questo script funziona per mantenere
      l'ordine ed i nome dei campi come visualizzati in tabella
      attributi, mentre per quanto riguarda i valori li esporta come
      salvati e non come visualizzati (le due cose possono essere
      diverse ad esempio nel caso di mappe valori). Purtroppo sono solo
      un dilettante con python, chi lo sa usare bene può fare
      sicuramente di meglio.</p>
    <p>Comunque partendo dal suggerimento di Rossella mi è venuto in
      mente che forse è possibile usare il riorganizzatore campi
      all'interno del modellizzatore grafico per impostare
      trasformazioni fisse, utile se bisogna esportare varie volte la
      tabella di uno stesso layer.<br>
      <br>
    </p>
    <div class="moz-cite-prefix">Il 29/04/2019 21:50, Marco Spaziani ha
      scritto:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAN8fdHiA8hioggwMAqvor3XNgL-P8joX79f-Y-+1kfyEcR2geQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Grazie anche da parte mia.</div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Il giorno lun 29 apr 2019 alle
          ore 20:45 Alessandro Perego <<a
            href="mailto:alsper78@gmail.com" moz-do-not-send="true">alsper78@gmail.com</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 bgcolor="#FFFFFF">
            <p>Grazie per aver risposto,<br>
              purtroppo ho un layer con circa 70 campi di cui 30 da
              esportare (ma è probabile che debba aggiungerne altri) e
              dover fare la riorganizzazione campi (cambiando l'ordine
              ed i nomi) ogni volta che devo esportare la tabella
              diventa un lavoraccio.<br>
              Per ora mi sono fatto uno script da copiare nella console
              python che sembra fare il lavoro.<br>
              Se a qualcuno può servire lo script è questo:<br>
              <br>
              #<br>
              #   Questo script consente di esportare la tabella
              attributi personalizzata del layer attivo<br>
              #   in un file formato testo con valori delimitati da
              tabulazione<br>
              #<br>
              from qgis.core import *<br>
              from qgis.utils import iface<br>
              from datetime import datetime<br>
              layer = iface.activeLayer()<br>
              timeNow = datetime.now().strftime('%Y%m%d-%H%M%S')<br>
              output = QgsProject.instance().readPath("./") + '/' + <a
                href="http://layer.name" target="_blank"
                moz-do-not-send="true">layer.name</a>() + '_table_' +
              timeNow + '.txt'<br>
              new = open(output,'w')<br>
              fieldList = []<br>
              fieldIdList = []<br>
              ATfields = layer.fields()<br>
              ATconfig = layer.attributeTableConfig()<br>
              ATcolumns = ATconfig.columns()<br>
              if len( ATcolumns ) > 0:<br>
                  #<br>
                  # riga di intestazione<br>
                  for ATcolumn in ATcolumns:<br>
                      if ATcolumn.hidden == 0:<br>
                          fieldName = ATcolumn.name<br>
                          fieldID =
              ATfields.indexFromName(ATcolumn.name)<br>
                          fieldIdList.append( fieldID )<br>
                          displayName = layer.attributeDisplayName(
              fieldID )<br>
                          fieldList.append( displayName )<br>
                  headRow = '\t'.join( map( str, fieldList ) )<br>
                  write = new.write( headRow )<br>
                  #<br>
                  # righe degli attributi<br>
                  count = 0<br>
                  for feature in layer.getFeatures():<br>
                      attribList = []<br>
                      for Id in fieldIdList:<br>
                          attribList.append( feature[Id] )<br>
                      featRow = '\t'.join( map( str, attribList ) )<br>
                      write = new.write( '\n' + featRow )<br>
                      count = count + 1<br>
                  #<br>
                  new.close()<br>
                  print( 'Operazione completata' )<br>
                  print( 'File creato:', output )<br>
                  print( 'numero di record:', count )<br>
                  print( 'numero di colonne:', len( fieldIdList ) )<br>
                  <br>
            </p>
            <p><br>
            </p>
            <div class="gmail-m_2069916120736453460moz-cite-prefix">Il
              29/04/2019 20:07, Rossella Di Bari ha scritto:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">
                <div>Ciao Alessandro,</div>
                <div>non conosco un modo diretto per esportare in foglio
                  di calcolo la tabella attributi come visualizzata, mi
                  spiace...</div>
                <div>Conosco invece il Riorganizzatore Campi, che peschi
                  tra gli strumenti di geoprocessing, e che ti crea un
                  nuovo vettore, riorganizzando le colonne e ridigitando
                  gli alias che avevi già dato. Le colonne nascoste
                  precedentemente andrebbero eliminate. Alla fine della
                  riorganizzazione dei campi viene rigenerato un nuovo
                  vettore, anche temporaneo, che salvi come foglio di
                  calcolo.</div>
                <div>Spero di esserti stata utile (o forse no perchè mi
                  sa che sei più navigato di me con Qgis ;) )</div>
                <div><br>
                </div>
                <div>Saluti a tutti<br>
                </div>
              </div>
              <div
                id="gmail-m_2069916120736453460DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
                <table style="border-top:1px solid rgb(211,212,222)">
                  <tbody>
                    <tr>
                      <td style="width:55px;padding-top:18px"><a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
                          target="_blank" moz-do-not-send="true"><img
src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif"
                            alt="" style="width: 46px; height: 29px;"
                            moz-do-not-send="true" width="46"
                            height="29"></a></td>
                      <td
style="width:470px;padding-top:17px;color:rgb(65,66,78);font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Mail
                        priva di virus. <a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
                          style="color:rgb(68,83,234)" target="_blank"
                          moz-do-not-send="true">www.avast.com</a> </td>
                    </tr>
                  </tbody>
                </table>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">Il giorno gio 25 apr
                  2019 alle ore 20:59 alper78 <<a
                    href="mailto:alsper78@gmail.com" target="_blank"
                    moz-do-not-send="true">alsper78@gmail.com</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">Ciao,<br>
                  sapete dirmi se c'è modo di esportare la tabella
                  attributi di un layer<br>
                  vettoriale mantenendo le caratteristiche con cui viene
                  visualizzata (cioè<br>
                  con i nomi alias, con l'ordine impostato in "Organizza
                  Colonne" ed<br>
                  escludendo le colonne nascoste)?<br>
                  Se copio le righe selezionate per poi incollarle in un
                  file di testo o in un<br>
                  foglio di calcolo mi perde gli alias e l'ordine
                  personalizzato delle<br>
                  colonne.<br>
                  <br>
                  Grazie<br>
                  <br>
                  <br>
                  <br>
                  <br>
                  -----<br>
                  Alessandro Perego<br>
                  <a href="http://www.alspergis.altervista.org"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">http://www.alspergis.altervista.org</a><br>
                  --<br>
                  Sent from: <a
href="http://osgeo-org.1560.x6.nabble.com/QGIS-Italian-User-f5250612.html"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">http://osgeo-org.1560.x6.nabble.com/QGIS-Italian-User-f5250612.html</a><br>
                  _______________________________________________<br>
                  QGIS-it-user mailing list<br>
                  <a href="mailto:QGIS-it-user@lists.osgeo.org"
                    target="_blank" moz-do-not-send="true">QGIS-it-user@lists.osgeo.org</a><br>
                  <a
                    href="https://lists.osgeo.org/mailman/listinfo/qgis-it-user"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-it-user</a><br>
                </blockquote>
              </div>
              <br clear="all">
              <br>
              -- <br>
              <div dir="ltr"
                class="gmail-m_2069916120736453460gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div>
                        <div><a
href="https://zxing.org/w/decode?u=https%3A%2F%2Fdocs.google.com%2Fuc%3Fexport%3Ddownload%26id%3D0B1-C0i5xe-F6elU0eVRRbjBRSTg%26revid%3D0B1-C0i5xe-F6NUdnWDJTcTV6RVlvdkhML2hLaEJYYTg4OG1FPQ"
                            target="_blank" moz-do-not-send="true"><img
src="https://docs.google.com/uc?export=download&id=0B1-C0i5xe-F6elU0eVRRbjBRSTg&revid=0B1-C0i5xe-F6NUdnWDJTcTV6RVlvdkhML2hLaEJYYTg4OG1FPQ"
                              alt="" moz-do-not-send="true"></a><img
                            alt="" moz-do-not-send="true"></div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <br>
              <fieldset
                class="gmail-m_2069916120736453460mimeAttachmentHeader"></fieldset>
              <pre class="gmail-m_2069916120736453460moz-quote-pre">_______________________________________________
QGIS-it-user mailing list
<a class="gmail-m_2069916120736453460moz-txt-link-abbreviated" href="mailto:QGIS-it-user@lists.osgeo.org" target="_blank" moz-do-not-send="true">QGIS-it-user@lists.osgeo.org</a>
<a class="gmail-m_2069916120736453460moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-it-user" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-it-user</a>
</pre>
            </blockquote>
            <div class="gmail-m_2069916120736453460moz-signature">-- <br>
              Alessandro Perego <a
                href="http://www.alspergis.altervista.org/"
                target="_blank" moz-do-not-send="true">www.alspergis.altervista.org</a></div>
          </div>
          _______________________________________________<br>
          QGIS-it-user mailing list<br>
          <a href="mailto:QGIS-it-user@lists.osgeo.org" target="_blank"
            moz-do-not-send="true">QGIS-it-user@lists.osgeo.org</a><br>
          <a
            href="https://lists.osgeo.org/mailman/listinfo/qgis-it-user"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-it-user</a><br>
        </blockquote>
      </div>
    </blockquote>
    <div class="moz-signature">-- <br>
      Alessandro Perego
      <a href="http://www.alspergis.altervista.org/">www.alspergis.altervista.org</a></div>
  </body>
</html>