input from dataset and dump output in folder

Swapnali
Level 3
input from dataset and dump output in folder

Hi Team,

How can I dump the value of string datatype from a dataset(excel format) to the folder in text file format using python?

like :FROM:

pathtext
mv.wavsdmgggggggggmgjsgajdmkdj

now I want to create a text file(mv.txt) for the value of text column and save it in

TO: the folder named Data, with  hierarchy: Data\test\pos\mv.txt

Kindly help us and thanks in advance.

 

 

 

0 Kudos
2 Replies
MickaelH
Dataiker

Hi,

Based on what you describe I would suggest to:

  1. create the proper filesystem connection corresponding to the root folder where you want to store the files (based on your example, it could be Data or Data\test or Data\test\pos
    1. please not that you can also specify a path from this root folder in the settings of the Folder that is created in the next step
  2. create a python recipe with a folder output based on the previous connection. The generated code snippet will provide you objects to get started: 
    1. the input dataset: you'll find the documentation on how to interact with a dataset here => https://doc.dataiku.com/dss/latest/python-api/datasets.html
    2. the output folder: you'll find the documentation on how to interact with a folder here => https://doc.dataiku.com/dss/latest/python-api/managed_folders.html
      1. more specifically you could use the following method to write your text file: https://doc.dataiku.com/dss/latest/python-api/managed_folders.html#dataiku.Folder.get_writer
      2. you will find an example in this section: https://doc.dataiku.com/dss/latest/connecting/managed_folders.html?highlight=get_writer#usage-in-pyt... (see "To write a file in the folder")
  3. code inside this python recipe the logic that corresponds to your need based on the input dataset

I hope this helps.

Regards,

Mickaรซl | R&D at Dataiku
sedky
Level 1

found solution but could not delete this comment.

0 Kudos