1 Reply Latest reply on Oct 12, 2015 11:29 PM by diego.medrano

    create except process for my Extract API CSV to TDE. But my python code can't read tde.Extract('SuperStoreCSVExtract.tde'). When there is existing file in current folder.

    Ruth Dong

      HI All,

       

      I am trying to create except process for my Extract API CSV to TDE. But my python code can't read or execute tde.Extract('SuperStoreCSVExtract.tde'). When there is an existing file in current folder. I am using Pythod 2.7.9.   and Tableau 9.0.4.  Can you please help ?

       

      Thank You

       

      # step1: Create the Extract File and open the .csv

      targetdir = 'C:\Extract API'

       

       

      os.chdir(targetdir)

      try:

          print os.getcwd()

          print 'get here'

          tdefile = tde.Extract('SuperStoreCSVExtract.tde')

          print tdefile

          print '2'

      except:

          print '333'

          os.remove('SuperStoreCSVExtract.tde')

          print 'get here2'

          tdefile = tde.Extract('SuperStoreCSVExtract.tde')

          print 'get here3'

       

      csvReader = csv.reader(open('SuperStoreCSV.csv', 'rb'), delimiter = ',', quotechar = '"')

       

      if tdefile.hasTable('Extract'):

          print '5'

          table = tdefile.openTable('Extract')

          tableDef = table.getTableDefinition()

          print '6'

      else:

       

      OUT PUT:

      >>>

      C:\Extract API

      get here

      <dataextract.Base.Extract object at 0x02DB0670>

      2

      5

      6

      >>>