how could we extract the attribute definition of all reader in the workspace , the idea is to build a technical document in word or excel, to define all the attributes
Hi @boubcher, you can read the schema definition of any dataset with the Schema (Any Format) reader. Each schema feature output from the reader will have a list attribute called "attribute{}" which contains the definition of all user attributes of a feature class. The list is a structured one consisting of these three members.
- attribute{}.name: Attribute name
- attribute{}.fme_data_type: FME generic data type
- attribute{}.native_data_type: Native data type of the attribute (format specific)
You can use the ListExploder to decompose the list into individual elements, and then write them into an Excel spreadsheet.
Hi @boubcher, you can read the schema definition of any dataset with the Schema (Any Format) reader. Each schema feature output from the reader will have a list attribute called "attribute{}" which contains the definition of all user attributes of a feature class. The list is a structured one consisting of these three members.
- attribute{}.name: Attribute name
- attribute{}.fme_data_type: FME generic data type
- attribute{}.native_data_type: Native data type of the attribute (format specific)
You can use the ListExploder to decompose the list into individual elements, and then write them into an Excel spreadsheet.
Thanks Takashi
Â
I came across the problem, but in my case I did not have access to the source_datasets, so I could not run the workspace, but I wanted to extract every user attribute. So what i did was to make a script to extract the data from the .fmw file and it goes as follows:
import xml.etree.cElementTree as ET
workspace = r'C:\Enter\Your\Workspace\Here.fmw'
with open(workspace) as f:
    lines = w]
    line = f.readline()
    while True:
        if not line:
            break
        if line.startswith('#!'):
            lines.append(line)
        elif line.startswith('#'):
            pass
        else:
            break
        line = f.readline()
    with open('fmw2xml.xml','w') as fw:
        fw.write(''.join(lines).replace('#! ',''))
xml =  ET.parse('fmw2xml.xml')
for feature_type in xml.iter('FEATURE_TYPE'):
    with open(f'{feature_type.attribÂ"NODE_NAME"]}.csv', 'w+') as csv:
        _header = False
        for child in feature_type.iter('FEAT_ATTRIBUTE'):
            if not _header:
                csv.write(';'.join(child.attrib.keys())+'\n')
                _header = True
            csv.write(';'.join(child.attrib.values())+'\n')
Now what this does it creates a csv file for every reader in your workspace, and inside each csv is the user attributes. code tested in py 3.6 , for 2.7 f strings must be converted to supported string format.
Hi @boubcher, you can read the schema definition of any dataset with the Schema (Any Format) reader. Each schema feature output from the reader will have a list attribute called "attribute{}" which contains the definition of all user attributes of a feature class. The list is a structured one consisting of these three members.
- attribute{}.name: Attribute name
- attribute{}.fme_data_type: FME generic data type
- attribute{}.native_data_type: Native data type of the attribute (format specific)
You can use the ListExploder to decompose the list into individual elements, and then write them into an Excel spreadsheet.
What about on a DB connection?