Python Transformations - Saving data to out/tables problem

I am a new Keboola user and just tested the python transformation feature. I tried to use a single Google Sheet table to perform a simple transformation and save the new table to the out/tables/result.csv.

When I run the code in the cell of the Jupyter notebook, the code runs fine and creates the desired result.csv file in the correct folder. However, when I run the same code as a Transformation within the same Workspace I receive the following error:

Failed to resolve destination for output table "result.csv".

Here is the code for the script:

import csv

csvlt = '\n'
csvdel = ','
csvquo = '"'
with open('in/tables/test-data-sheet1.csv', mode='rt', encoding='utf-8') as in_file, open('out/tables/result.csv', mode='wt', encoding='utf-8') as out_file:
    writer = csv.DictWriter(out_file, fieldnames=['col1', 'col2'], lineterminator=csvlt, delimiter=csvdel, quotechar=csvquo)
    writer.writeheader()

    lazy_lines = (line.replace('\0', '') for line in in_file)
    reader = csv.DictReader(lazy_lines, lineterminator=csvlt, delimiter=csvdel, quotechar=csvquo)
    for row in reader:
        # do something and write row
        writer.writerow({'col1': row['Date'] + '_some_string', 'col2': float(row['All_sessions']) + 1})

I feel this is a very basic thing described in the tutorial. Obviously, I am doing something wrong. Any suggestions?

4 replies