unzipping using python node
I’m trying to unzip and rename the unzipped file using python node, unzipping is working fine for me but when I’m putting rename file code it’s throwing errors, can you please let me know if there’s any best way to unzip the file ?
-
The generic way to handle renaming a file in python is:
import os
os.rename(r'file path\OLD file name.filetype',r'file path\NEW file name.filetype')e.g. for Windows:
import os
os.rename(r'C:\Users\Bob\Desktop\Test\test_file.txt', r'C:\Users\Bob\Desktop\Test\new_test_file.txt')and for Linux:
import os
os.rename(r'/home/Bob/Test/test_file.txt', r'/home/Bob/Test/new_test_file.txt')The "r" in front of the file name is not strictly necessary with Linux since it uses forward slashes for the path separators rather than the Backslash with Windows. However, it is best practice to include it to make the code more portable.
The import statement should be included at the start of your script. When using the Transform node it is best to include this in the ConfigureFields script as the import is then performed once rather than for each record.
We understand you have had issues posting to the forum - were you using Internet Explorer 11 at the time? In common with many applications provided by third-party vendors, Zendesk announced earlier this year that they would cease support for IE11 at the end of this year and that new functionality may not work in IE11. Infogix recommend the use of Chrome with Analyze.
Please sign in to leave a comment.
Comments
1 comment