<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"var\(--ff-mono\)";
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:inherit;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-CA" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">There should be a method renameAttribute as part of QgsVectorLayer class.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">You can do something like that:<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm"><o:p> </o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm">layer = iface.activeLayer()<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm">for field in layer.pendingFields():<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm">    if field.name() == 'old':<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm">        with edit(layer):<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm">            idx = layer.fieldNameIndex(field.name())<o:p></o:p></span></p>
<p class="MsoNormal" style="vertical-align:baseline"><span style="font-size:10.0pt;font-family:"inherit",serif;border:none windowtext 1.0pt;padding:0cm">            layer.renameAttribute(idx, 'new')</span><span style="font-size:10.0pt;font-family:"var(--ff-mono)",serif"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Good luck!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Marian<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Qgis-user <qgis-user-bounces@lists.osgeo.org>
<b>On Behalf Of </b>Ursula Heinze<br>
<b>Sent:</b> June 1, 2021 5:26 AM<br>
<b>To:</b> Qgis-user@lists.osgeo.org<br>
<b>Subject:</b> [EXT] [Qgis-user] Rename column<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:solid #9C6500 1.0pt;padding:2.0pt 2.0pt 2.0pt 2.0pt">
<p class="MsoNormal" style="line-height:12.0pt;background:#FFEB9C"><span lang="DE" style="font-size:10.0pt;color:#9C6500">CAUTION:</span><span lang="DE" style="font-size:10.0pt;color:black"> This email originated from outside of the organization. If you do
 not recognize the sender or you are not certain the content is safe, then do not click on any links or open any attachments.
<br>
</span><span lang="DE" style="font-size:10.0pt;color:#9C6500">AVERTISSEMENT :</span><span lang="DE" style="font-size:10.0pt;color:black"> Ce courriel provient d’une source externe à l’organisation. Si vous ne reconnaissez pas l’expéditeur ou si vous doutez
 de la sécurité du contenu, ne cliquez sur aucun lien et n’ouvrez aucune pièce jointe.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="DE"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="DE">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE">I have a little problem with the field calculator. I want to rename a column, and I don´t find any way to do it.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE">Now I tried to copy the field values in a new column with the right name, and am also not successful. Has anybody an idea for me, how to solve the problem? Many thanks in advance!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE">Ursula Heinze<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="DE">Gesendet von <a href="https://urldefense.com/v3/__https:/go.microsoft.com/fwlink/?LinkId=550986__;!!P0kg3YazkQ!W94jRKLCVMrbhztEtw9jiDUPiECzoEscG5JxdIsa3_vpvGZuh4v0QGxdDJLtJD0Tmg$">
Mail</a> für Windows 10<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE"><o:p> </o:p></span></p>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
This electronic message, as well as any transmitted files included in the electronic message, may contain privileged or confidential information and is intended solely for the use of the individual(s) or entity to which it is addressed. If you have received
 this electronic message in error please notify the sender immediately and delete the electronic message. Any unauthorized copying, disclosure or distribution of the electronic message is strictly forbidden. NAV CANADA accepts no liability for any damage caused
 by any virus and/or other malicious code transmitted by this electronic communication.<br>
<br>
Le présent message électronique et tout fichier qui peut y être joint peuvent contenir des renseignements privilégiés ou confidentiels destinés à l’usage exclusif des personnes ou des organismes à qui ils s’adressent. Si vous avez reçu ce message électronique
 par erreur, veuillez en informer l’expéditeur immédiatement et supprimez le. Toute reproduction, divulgation ou distribution du présent message électronique est strictement interdite. NAV CANADA n’assume aucune responsabilité en cas de dommage causé par tout
 virus ou autre programme malveillant transmis par ce message électronique.<br>
</font>
</body>
</html>