Skip to main content

#Assign0 debatiendo

I'm working with a Pandas dataframe.

I have all of my data loaded and all of the manipulations I would like to perform, done.

I'm looking for the specific lines of code which can take this dataframe and copy the rows to a table which I have defined as part of a .tde extract.

If anyone has experience with this I'd love to see what you wrote. There are examples online for using a .csvreader with python which loops through the rows and adds them as they are being read but I can't find any example of how to take data stored in a dataframe and apply it to a table defined as part of an extract.

8 respuestas
  1. 1 feb 2016, 18:24

    Colin, I know this is older did you ever get your answer on this?

     

    I ran it across it doing research and I have solved this using Pandas. 

     

    I followed along the API instructions to create a TDE from Tableau then used a DataFrame to populate the data in a loop reading through all the rows.  I pasted a sample Python script I wrote below.  Using some dummy data I created the TDE file.

     

    I am sure there are other ways to make this more efficient but this worked for me.

     

    Regards,

     

    Frank

     

    import dataextract as tde

    import os

    import pandas as pd

    import numpy as np

    import datetime as dt

     

    try:

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

    except:

        os.remove('data.tde')

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

     

    ⌗tdefile = tde.Extract('data.tde')

    tableDef = tde.TableDefinition()

    tableDef.addColumn('ID', tde.Type.CHAR_STRING) #0

    tableDef.addColumn('Name', tde.Type.CHAR_STRING) #1

    tableDef.addColumn('Age', tde.Type.INTEGER) # 2

    table = tdefile.addTable('Extract', tableDef)

    newrow = tde.Row(tableDef)

     

    data = pd.read_excel('data.xlsx')

    for i in range(0,data.shape[0]):

        newrow.setCharString(0, str(data.ix[i,0]))

        newrow.setCharString(1, str(data.ix[i,1]))

        newrow.setInteger(2, int(data.ix[i,2]))

        table.insert(newrow)

     

    tdefile.close()

0/9000

I am getting below error

 

The following has evaluated to null or missing:

==> pathwayRequirementGroupedUnembeddableResources.pathwayRequirement.availability [in template "layout/rapidtheme/user/consumption/include/consumption-content/course-pathway/downloads.ftl" at line 13, column 55]

 

----

Tip: It's the step after the last dot that caused this error, not those before it.

----

Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

----

 

----

FTL stack trace ("~" means nesting-related):

- Failed at: #assign pathwayRequirementAvailabilit... [in template "layout/rapidtheme/user/consumption/include/consumption-content/course-pathway/downloads.ftl" at line 13, column 13]

- Reached through: #include "/layout/rapidtheme/user/con... [in template "layout/rapidtheme/user/consumption/content-course-pathway-downloads.ftl" at line 5, column 9]

- Reached through: #include path [in template "common/macros.ftl" in macro "include" at line 50, column 9]

- Reached through: @include content [in template "layout/rapidtheme/user/layout.ftl" at line 57, column 45]

----

2 respuestas
0/9000

I am getting below error

 

The following has evaluated to null or missing:

==> pathwayRequirementGroupedUnembeddableResources.pathwayRequirement.availability [in template "layout/rapidtheme/user/consumption/include/consumption-content/course-pathway/downloads.ftl" at line 13, column 55]

 

----

Tip: It's the step after the last dot that caused this error, not those before it.

----

Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

----

 

----

FTL stack trace ("~" means nesting-related):

- Failed at: #assign pathwayRequirementAvailabilit... [in template "layout/rapidtheme/user/consumption/include/consumption-content/course-pathway/downloads.ftl" at line 13, column 13]

- Reached through: #include "/layout/rapidtheme/user/con... [in template "layout/rapidtheme/user/consumption/content-course-pathway-downloads.ftl" at line 5, column 9]

- Reached through: #include path [in template "common/macros.ftl" in macro "include" at line 50, column 9]

- Reached through: @include content [in template "layout/rapidtheme/user/layout.ftl" at line 57, column 45]

----

1 respuesta
  1. 28 ene 2020, 18:30

    Hi @Sachin Bankar​ ,

    All links are working fine, will you please let me know, which file you are not able to download. You can cross-check it through different browser.

     

    Regards,

     

    Lalit Panwar

0/9000