#1 Fri 07 September 2007 16:34
- 20centimes1
- Juste Inscrit !
- Date d'inscription: 15 Feb 2007
- Messages: 4
Augmenter le nombre de caractères dans un champ
Bonjour,
je n'ai pas trouvé de réponse à ce problème dans les anciens posts, pourtant, je ne dois pas être le premier à me poser la question. Sous ArcView 3.2, comment augmenter la largeur d'un champ (pour passer de 16 à 32 ou 40 carcatères) dans une table attributaire?
Meric d'avance.
Hors ligne
#2 Fri 07 September 2007 17:16
- Sylvain T.
- Membre
- Lieu: Musée de l'Homme, Paris France
- Date d'inscription: 7 Sep 2005
- Messages: 742
- Site web
Re: Augmenter le nombre de caractères dans un champ
Hello,
Pas de possibilité d'augmenter le nombre de caractère d'un champ en natif (peut-être exsite-t-il un script ou une extension).
Il y a cependant une solution manuelle:
1. créer un nouveau champ avec le nb de caractère voulu.
2. recopier le contenu du champ dans le nouveau avec la calculatrice.
3. supprimer l'ancien champ.
Cordialement,
Sylvain
Hors ligne
#3 Fri 07 September 2007 22:46
- 20centimes1
- Juste Inscrit !
- Date d'inscription: 15 Feb 2007
- Messages: 4
Re: Augmenter le nombre de caractères dans un champ
Ok, merci beaucoup! Très basique en effet, mais ça marche!
Hors ligne
#4 Mon 10 September 2007 17:07
Re: Augmenter le nombre de caractères dans un champ
Hello,
Les ET Geowizards font ca aussi.
Il faut aller dans l'onglet Basic puis Choisir "Redefine Fields".
Le descriptif avec quelques trad rapide :
Redefine Fields Wizard
Change field names and definitions.
(Change les nom de champ et leur définition)
Inputs:
(Entrée :)
A feature layer
(Une couche d'entités)
Point
Polyline
Polygon
New field names, length, precision, scale
Outputs:
(Sortie :)
A new feature class.
(Une nouvelle couche d'entités)
How to use:
(Mode d'emploi)
Select a layer to be exported and a location for the new feature class
A list of all the fields in the layer is presented in a grid where the user can change the names and definitions of the fields
Notes:
The type of the fields can't be changed
(Le type de champ ne peut pas être changé)
The new field names should be max 10 characters long
(Le nouveau champ ne peut avoir plus de 10 caractères)
If the sorce layer is a Personal Geodatabase layer the numeric fields will be reported incorrectly in the grid with Precision = 0 and Scale = 0.
(attention si le fichier vient d'une geodatabase)
If the Precision and Scale are incorrectly set to 0, the original field definition will be used.
(s'il y a des erreurs dans la saisie la définition utilisée sera l'originale)
Hors ligne
#5 Tue 11 September 2007 10:58
- Sylvain T.
- Membre
- Lieu: Musée de l'Homme, Paris France
- Date d'inscription: 7 Sep 2005
- Messages: 742
- Site web
Re: Augmenter le nombre de caractères dans un champ
Hello,
Euh Robin, on parle d'AV3.x. L'extension ET Geowizards Tools pour cette version ne comprend pas d'outil de manipulation de champs.
Sous AV3.x, il y a bien une extension qui fait (notamment) cela, PowerStructure, mais elle est payante.
Amicalement,
Sylvain
Hors ligne
#6 Tue 11 September 2007 11:28
Re: Augmenter le nombre de caractères dans un champ
Woups, bien vu, mes excuses.
Robin, confus.
Ps : Pour me rattraper, et pour ceux qui ne connaissent pas et qui bosse encore sur ArcView 3.x, un p'tit lien vers les Xtools version Arview 3.x : http://arcscripts.esri.com/details.asp?dbid=11526. Je n'y ai pas trouvé la fonction qui change le nom des champs mais ca fait quelques trucs sympa
Hors ligne
#7 Tue 11 September 2007 11:33
Re: Augmenter le nombre de caractères dans un champ
Ah si, j'ai quand même trouvé un truc (voir ci dessous)
C'est un code trouvé ici avec d'autres trucs utile sur cette page
MOD.AVE (4.2K) -- Renames or Modifies Fields
5/29/98
You can't directly modify fields in ArcView, but this script works around that by creating a new table and copying over the values. Allows you to rename fields, redefine them (e.g. change width or precision), and convert CHAR fields to DECIMAL and vice versa. The old .DBF file is given a .BAK extension and the table document recreated for the new file. Not recommended for use on Table documents created using FTheme.EditTable.
En somme ca fait un peu pareil que l'astuce de Sylvain, qui est plus simple, je pense.
Attention à l'utilisation du code, il y a un avertissement sur le type de tables traitées, j'ai l'impression qu'il s'agit des tables liées à un Ftheme.
Code:
' Table.Modify
' Renames or modifies fields in a Table document
' Assumes that the base table is a shapefile or dBase (.DBF) file
' Saves the old table with a .BAK extension
' At this point, only DECIMAL and CHAR fields are supported
'**** see if directory and dBase file write-protected
theTable = av.GetActiveDoc
tabName = theTable.GetName
tabExt = theTable.GetWin.ReturnExtent
tabOrigin = theTable.GetWin.ReturnOrigin
theVTab = theTable.GetVTab
theFName = theVTab.GetBaseTableFileName
theDir = theFName.ReturnDir
theTitle = "Modify"
if (File.IsWritable(theDir).Not) then
MsgBox.Error("Cannot write to directory.",theTitle)
return nil
end
if (File.IsWritable(theFName).Not) then
MsgBox.Error("File is not writable.",theTitle)
return nil
end
'**** get list of field names
fl = List.Make
for each f in theVTab.GetFields
fnm = f.GetName
ft = f.GetType.AsString.AsTokens("_").Get(1)
if ((ft = "CHAR") or (ft = "DECIMAL")) then
fl.Add(fnm.AsString)
end
end
'**** get modifications
f_list = List.Make
modlist = List.Make
modfield = true
theMsg = "Enter modifications"
theLabels = {"Name","Type","Width","Precision"}
while (modfield)
f = MsgBox.ChoiceAsString(fl,"Select field to modify",theTitle)
if (f = nil) then
return nil
elseif (f_list.FindByValue(f) > -1) then
MsgBox.Info("Field already selected",theTitle)
else
theField = theVTab.FindField(f)
theType = theField.GetType.AsString.AsTokens("_").Get(1)
theWidth = theField.GetWidth.AsString
thePrecision = theField.GetPrecision.AsString
theDefaults = {f,theType,theWidth,thePrecision}
result = MsgBox.MultiInput(theMsg,theTitle,theLabels,theDefaults)
if (result = nil) then
return nil
end
newName = result.Get(0)
nt = result.Get(1)
if ((nt = "CHAR") or (nt = "DECIMAL")) then
newType = ("#FIELD_"+nt).AsEnum
else
MsgBox.Error("Unsupported type",theTitle)
return nil
end
newWidth = result.Get(2).AsNumber
newPrecision = result.Get(3).AsNumber
f_list.Add(f)
modlist.Add({newName,newType,newWidth,newPrecision})
end
modfield = MsgBox.MiniYesNo("Modify another field?",false)
end
'**** generate field list
oldFields = List.Make
newFields = List.Make
for each f in theVTab.GetFields
fnm = f.GetName
if (fnm <> "Shape") then
i = f_list.FindByValue(fnm)
if (i > -1) then
nm = modlist.Get(i).Get(0)
nt = modlist.Get(i).Get(1)
nw = modlist.Get(i).Get(2)
np = modlist.Get(i).Get(3)
nf = Field.Make(nm,nt,nw,np)
newFields.Add(nf)
else
newFields.Add(f.Clone)
end
oldFields.Add(f)
end
end
'**** generate scratch file
tmpFName = theDir.MakeTmp("tmp","dbf")
tmpVTab = VTab.MakeNew(tmpFName,dBase)
tmpVTab.AddFields(newFields)
'**** populate records
i_last = newFields.Count - 1
numdone = 0
numrec = theVTab.GetNumRecords
for each r in theVTab
r2 = tmpVTab.AddRecord
for each i in 0..i_last
of = oldFields.Get(i)
nf = newFields.Get(i)
v = theVTab.ReturnValue(of,r)
if (nf.IsTypeString) then
if (v.Is(Number)) then
theVal = v.AsString
else
theVal = v
end
else
if (v.Is(String)) then
theVal = v.AsNumber
else
theVal = v
end
end
tmpVTab.SetValue(nf,r2,theVal)
end
numdone = numdone + 1
av.SetStatus(numdone / numrec * 100)
end
tmpVTab.Flush
tmpVTab.DeActivate
tmpVTab = nil
theVTab.DeActivate
theVTab = nil
av.GetProject.RemoveDoc(theTable)
theTable = nil
av.PurgeObjects
av.ClearStatus
'**** rename files
bakFName = FileName.Make(theFName.AsString)
bakFName.SetExtension("bak")
File.Copy(theFName,bakFName)
File.Copy(tmpFName,theFName)
File.Delete(tmpFName)
'**** create new table doc
theVTab = VTab.Make(theFName,false,false)
theTable = Table.Make(theVTab)
av.GetProject.AddDoc(theTable)
theTable.SetName(tabName)
theTable.GetWin.MoveTo(tabOrigin.GetX,tabOrigin.GetY)
theTable.GetWin.Resize(tabExt.GetX,tabExt.GetY)
theTable.GetWin.Activate
return nilHors ligne
#8 Tue 11 September 2007 11:44
- Sylvain T.
- Membre
- Lieu: Musée de l'Homme, Paris France
- Date d'inscription: 7 Sep 2005
- Messages: 742
- Site web
Re: Augmenter le nombre de caractères dans un champ
Hello,
J'ai aussi codé quelques outils pour les tables, dont renommer, convertir, agrandir, qui sont inclus dans cette extension.
A+
Sylvain
Hors ligne


