Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

placing file in SFTP

Scobbyy2k3
Level 3
placing file in SFTP

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

0 Kudos
5 Replies
MiguelangelC
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?

 

0 Kudos
Scobbyy2k3
Level 3
Author

how do i check that ?

0 Kudos
MiguelangelC
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.

0 Kudos
Scobbyy2k3
Level 3
Author

no it does not

0 Kudos
Scobbyy2k3
Level 3
Author

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

0 Kudos