Data360 Analyze

 View Only
  • 1.  Importing Files from ZIP File

    Employee
    Posted 06-25-2020 09:26

    I need to import CSV files that are contained in a ZIP. Is it possible for Data360 to either unzip or import the CSV files from a ZIP? Any help would be appreciated. 

    I'm using Data360 Analyze v3.6.1.6294.

    Thanks, Josh



  • 2.  RE: Importing Files from ZIP File

    Employee
    Posted 06-25-2020 10:23

    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.



  • 3.  RE: Importing Files from ZIP File

    Employee
    Posted 06-25-2020 10:31

    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



  • 4.  RE: Importing Files from ZIP File

    Employee
    Posted 06-25-2020 11:31

    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

     

     



  • 5.  RE: Importing Files from ZIP File

    Employee
    Posted 06-25-2020 12:00

    That worked like a charm! Thanks again Adrian.

    Josh