Writing out a tsv

Options
Scobbyy2k3
Scobbyy2k3 Partner, Registered Posts: 26 Partner

I am writing out a tsv file in Python

I have written out the code below but still get an error. Please kindly help make ad

# Compute recipe outputs
# TODO: Write here your actual code that computes the outputs
# NB: DSS supports several kinds of APIs for reading and writing data. Please see doc.

files = glob.glob(os.path.join(combined_file.get_path(), 'combined_file_*.tsv'))

# Find latest modifiled file
latest_file_df = max(files , key = os.path.getmtime)

# Write recipe outputs
latest_file = dataiku.Dataset("latest_file")
latest_file.write_schema_from_dataframe(latest_file_df)


Operating system used: windows

Tagged:

Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,209 Dataiker
    Answer ✓
    Options

    Hi @Scobbyy2k3
    ,

    The latest_file_df should be a pandas dataframe. So you can use something like:

    latest_file_actual_df = pd.read_csv(latest_file_df, sep='\t')

    latest_file.write_schema_from_dataframe(latest_file_actual_df)

    Let me know if that helps if not please share the exact error you are seeing.

    Thanks,

Answers

Setup Info
    Tags
      Help me…