We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.

Importing Files from ZIP File

Comments

4 comments

  • Avatar
    Adrian Williams

    You can use the Python zipfile module in a Transform node to perform the extraction of all files into a specified directory:

    Note the use of a raw string ( r"C:\foo\bar" ) to escape the backslash characters in the Windows file paths

    A Directory List node can be configured to list all files in the specified directory that match a pattern:

    Finally, a CSV/Delimited node is used configured to read the filenames output by the Directory List node:

    If the fields in the .csv files are not the same you will need to set the ConcatenationMode on the CSV/Delimited node.

    0
    Comment actions Permalink
  • Avatar
    Joshua Campbell

    Thanks Adrian for the help. In this scenario the file name for the ZIP is dynamic. An example is US1_Multiple_YYYYMMDD_HHMM_Import.zip "YYYYMMDD_HHMM" is something like 20200625_1330. How can I have it be dynamic?

    Thanks,
    Josh

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    1) If the value is coming from an upstream node then you can delete the current SourceFile = ... line in the ConfigureFields script and put a corresponding statement in the ProcessRecords script.

    SourceFile = in1.MyZipFileField 

    You will also need to move the code that extracts the files from ConfigureFields (lines 17 - 20) and put it into the ProcessRecords script (after the last line)

     

    2) If the value is being typed in then you would need to a Data Flow Property Reference or a Run Property Reference and replace the contents of the string in the SourceFile = r".." statement with the Data Flow Property Reference or a Run Property Reference. The existing statement in the code would then be something ike:

     

    SourceFile = r"{{^MyNewPropertyRef^}}"

    See the Defining properties topic and Using property references topic in the Help documentation.

    You may want to set the property type as 'Filename' as this would present a file picker in the UI

     

     

    0
    Comment actions Permalink
  • Avatar
    Joshua Campbell

    That worked like a charm! Thanks again Adrian.

    Josh

    0
    Comment actions Permalink

Please sign in to leave a comment.