Hi, I’m trying to unzip a file in a python transform, but running into a FileNotFound error when reading from my input file. The input file here (RMK_TIE.bcp) is pulled from an SFTP sync into a dataset (rmk_tie_bcp), and both the input file name and input dataset name are throwing FileNotFound errors when I try to preview the transform, even though I was able to select the input dataset under Input. Not sure what I’m missing here, maybe someone else might have some thoughts?
Code to unzip file:
def compute(foundry_input, foundry_output, ctx):
input_fs = foundry_input.filesystem()
output_fs = foundry_output.filesystem()
input_path_bcp = "RMK_TIE.bcp"
output_path = "rmk_tie_unzipped"
with tempfile.NamedTemporaryFile() as temp:
try:
with input_fs.open(input_path_bcp, 'rb') as newest: # Line throwing error
shutil.copyfileobj(newest, temp)
temp.flush()
with output_fs.open(output_path, 'wb') as out:
input_file = input_fs.open(foundry_input.path)
data = input_file.read(CHUNK_SIZE)
while data:
out.write(data)
data = input_file.read(CHUNK_SIZE)