placing file in SFTP

Scobbyy2k3
Scobbyy2k3 Partner, Registered Posts: 26 Partner
edited July 16 in Using Dataiku

i created folder and changed the information for the folder to an SFTP .

Below is my code :

# time
import time
current_day = time.strftime("%Y%m%d")

name = "REGN_CONFIG_VALUES_"+current_day+".xlsx"

path = os.path.join(new_file_info["path"], name)

writer = pd.ExcelWriter(path)

study_config_values_stacked_distinct_df.to_excel(writer, sheet_name='Study Config Values',index=False, encoding='utf-8')

latest_file_data_df.to_excel(writer, sheet_name='Country Config Values',index=False, encoding='utf-8')

latest_file_data_df1.to_excel(writer, sheet_name='Site Config Values',index=False, encoding='utf-8')

latest_file_data_df2.to_excel(writer, sheet_name='Regn Codelist Values',index=False, encoding='utf-8')

writer.save()

I get this error each time i run the code :

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-8-76c9459ddcf4> in <module>
     43 name = "REGN_CONFIG_VALUES_"+current_day+".xlsx"
     44 
---> 45 path = os.path.join(new_file_info["path"], name)
     46 
     47 writer = pd.ExcelWriter(path)

KeyError: 'path'

Operating system used: windows

Answers

  • Miguel Angel
    Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker

    Hi,

    The "KeyError: 'path'" exception is telling us there was an issue retrieving the key you were looking for. This error normally occurs when trying to access a key that is not in the dictionary.

    Can you doublecheck the "new_file_info" dictionary has a "path" key?

  • Scobbyy2k3
    Scobbyy2k3 Partner, Registered Posts: 26 Partner

    how do i check that ?

  • Scobbyy2k3
    Scobbyy2k3 Partner, Registered Posts: 26 Partner

    no it does not

  • Scobbyy2k3
    Scobbyy2k3 Partner, Registered Posts: 26 Partner

    How can i have my sftp sharing same path information in the folder?

  • Miguel Angel
    Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker

    Hi,

    From the snippet shared we do not know what 'new_file_info' is or how it has been constructed. Since we have in the snippet 'new_file_info["path"]', we can make the assumption it is a dictionary that expects to have a 'path' key.

    In python, you can print all the keys of a dictionary by running: print(new_file_info.keys())

    If as I suspect the 'path' key does not exist, you'd need to modify your code or contact the code's author to fix this.

Setup Info
    Tags
      Help me…