hoverinc / tableau-utilities

A module and CLI Utility for managing Tableau objects, locally, and in Tableau Online.
MIT License
4 stars 1 forks source link

Column attribute #80

Open jaybythebay opened 4 months ago

jaybythebay commented 4 months ago

When using an extract based on a text file I got an error due to attributes missing from the relation. This should be very low priority to fix since we generally use databases with this package.

{
  '@class': 'federated',
  'named-connections': {
    'named-connection': {
      '@caption': 'CA',
      '@name': 'textscan.0bo2ohm17ohspk1gz2xrp0esve9p',
      'connection': {
        '@class': 'textscan',
        '@directory': '/Users/jayrosenthal/Downloads/namesbystate (1) 2',
        '@filename': 'CA.TXT',
        '@server': '',
        '@workgroup-auth-mode': 'as-is'
      }
    }
  },
  '_.fcp.ObjectModelEncapsulateLegacy.false...relation': {
    '@connection': 'textscan.0bo2ohm17ohspk1gz2xrp0esve9p',
    '@name': 'CA.TXT',
    '@table': '[CA#TXT]',
    '@type': 'table',
    'columns': {
      '@character-set': 'UTF-8',
      '@header': 'no',
      '@locale': 'en_US',
      '@separator': ',',
      'column': [
        {
          '@datatype': 'string',
          '@name': 'F1',
          '@ordinal': '0'
        },
        {
          '@datatype': 'string',
          '@name': 'F2',
          '@ordinal': '1'
        },
        {
          '@datatype': 'integer',
          '@name': 'F3',
          '@ordinal': '2'
        },
        {
          '@datatype': 'string',
          '@name': 'F4',
          '@ordinal': '3'
        },
        {
          '@datatype': 'integer',
          '@name': 'F5',
          '@ordinal': '4'
        }
      ]
    }
  },
  '_.fcp.ObjectModelEncapsulateLegacy.true...relation': {
    '@connection': 'textscan.0bo2ohm17ohspk1gz2xrp0esve9p',
    '@name': 'CA.TXT',
    '@table': '[CA#TXT]',
    '@type': 'table',
    'columns': {
      '@character-set': 'UTF-8',
      '@header': 'no',
      '@locale': 'en_US',
      '@separator': ',',
      'column': [
        {
          '@datatype': 'string',
          '@name': 'F1',
          '@ordinal': '0'
        },
        {
          '@datatype': 'string',
          '@name': 'F2',
          '@ordinal': '1'
        },
        {
          '@datatype': 'integer',
          '@name': 'F3',
          '@ordinal': '2'
        },
        {
          '@datatype': 'string',
          '@name': 'F4',
          '@ordinal': '3'
        },
        {
          '@datatype': 'integer',
          '@name': 'F5',
          '@ordinal': '4'
        }
      ]
    }
  },
  'metadata-records': {
    'metadata-record': [
      {
        '@class': 'capability',
        'remote-name': None,
        'remote-type': '0',
        'parent-name': '[CA.TXT]',
        'remote-alias': None,
        'aggregation': 'Count',
        'contains-null': 'true',
        'attributes': {
          'attribute': [
            {
              '@datatype': 'string',
              '@name': 'character-set',
              '#text': '"UTF-8"'
            },
            {
              '@datatype': 'string',
              '@name': 'collation',
              '#text': '"en_US"'
            },
            {
              '@datatype': 'string',
              '@name': 'field-delimiter',
              '#text': '","'
            },
            {
              '@datatype': 'string',
              '@name': 'header-row',
              '#text': '"false"'
            },
            {
              '@datatype': 'string',
              '@name': 'locale',
              '#text': '"en_US"'
            },
            {
              '@datatype': 'string',
              '@name': 'single-char',
              '#text': '""'
            }
          ]
        }
      },
      {
        '@class': 'column',
        'remote-name': 'F1',
        'remote-type': '129',
        'local-name': '[F1]',
        'parent-name': '[CA.TXT]',
        'remote-alias': 'F1',
        'ordinal': '0',
        'local-type': 'string',
        'aggregation': 'Count',
        'scale': '1',
        'width': '1073741823',
        'contains-null': 'true',
        'collation': {
          '@flag': '0',
          '@name': 'LEN_RUS'
        },
        '_.fcp.ObjectModelEncapsulateLegacy.true...object-id': '[CA.TXT_C749C47C63624ED5B6061FCA4707F1EA]'
      },
      {
        '@class': 'column',
        'remote-name': 'F2',
        'remote-type': '129',
        'local-name': '[F2]',
        'parent-name': '[CA.TXT]',
        'remote-alias': 'F2',
        'ordinal': '1',
        'local-type': 'string',
        'aggregation': 'Count',
        'scale': '1',
        'width': '1073741823',
        'contains-null': 'true',
        'collation': {
          '@flag': '0',
          '@name': 'LEN_RUS'
        },
        '_.fcp.ObjectModelEncapsulateLegacy.true...object-id': '[CA.TXT_C749C47C63624ED5B6061FCA4707F1EA]'
      },
      {
        '@class': 'column',
        'remote-name': 'F3',
        'remote-type': '20',
        'local-name': '[F3]',
        'parent-name': '[CA.TXT]',
        'remote-alias': 'F3',
        'ordinal': '2',
        'local-type': 'integer',
        'aggregation': 'Sum',
        'contains-null': 'true',
        '_.fcp.ObjectModelEncapsulateLegacy.true...object-id': '[CA.TXT_C749C47C63624ED5B6061FCA4707F1EA]'
      },
      {
        '@class': 'column',
        'remote-name': 'F4',
        'remote-type': '129',
        'local-name': '[F4]',
        'parent-name': '[CA.TXT]',
        'remote-alias': 'F4',
        'ordinal': '3',
        'local-type': 'string',
        'aggregation': 'Count',
        'scale': '1',
        'width': '1073741823',
        'contains-null': 'true',
        'collation': {
          '@flag': '0',
          '@name': 'LEN_RUS'
        },
        '_.fcp.ObjectModelEncapsulateLegacy.true...object-id': '[CA.TXT_C749C47C63624ED5B6061FCA4707F1EA]'
      },
      {
        '@class': 'column',
        'remote-name': 'F5',
        'remote-type': '20',
        'local-name': '[F5]',
        'parent-name': '[CA.TXT]',
        'remote-alias': 'F5',
        'ordinal': '4',
        'local-type': 'integer',
        'aggregation': 'Sum',
        'contains-null': 'true',
        '_.fcp.ObjectModelEncapsulateLegacy.true...object-id': '[CA.TXT_C749C47C63624ED5B6061FCA4707F1EA]'
      }
    ]
  }
}

The error occured in the columns section:

 'columns': {
      '@character-set': 'UTF-8',
      '@header': 'no',
      '@locale': 'en_US',
      '@separator': ',',

Traceback

Traceback (most recent call last):
  File "/Users/jayrosenthal/code/tableau-utilities/venv/bin/tableau_utilities", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/jayrosenthal/code/tableau-utilities/venv/lib/python3.12/site-packages/tableau_utilities/scripts/cli.py", line 487, in main
    args.func(args, server)
  File "/Users/jayrosenthal/code/tableau-utilities/venv/lib/python3.12/site-packages/tableau_utilities/scripts/datasource.py", line 72, in datasource
    ds = Datasource(datasource_path)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jayrosenthal/code/tableau-utilities/venv/lib/python3.12/site-packages/tableau_utilities/tableau_file/tableau_file.py", line 146, in __init__
    self.connection: tfo.ParentConnection = self.__get_section(tfo.ParentConnection)
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jayrosenthal/code/tableau-utilities/venv/lib/python3.12/site-packages/tableau_utilities/tableau_file/tableau_file.py", line 210, in __get_section
    raise TableauFileError(f'{err}\n\nPre-transform {obj.tag} attributes: {item}') from err
tableau_utilities.tableau_file.tableau_file.TableauFileError: Relation.__init__() got an unexpected keyword argument 'columns'