Question
I have files with multiple extensions such as .log, .bat, etc. mixed in a directory. Is it possible to read only files with .csv extension from those files?
Answer
Yes, it is possible to read all .csv files in a directory.
For the file names obtained in Get List of File Names operation, use Conditional Branch operation in Loop by Number of Data operation to check whether each file name contains a specific string.
Procedure
- Obtain the names of files or directories in a directory using Get List of File Names operation, and output the names obtained using [file]-[name] in the output schema of the operation.
- Assign one of the names to a string-type script variable with Assign Variables operation of Variable Mapper.
- By passing the result of Get List of File Names operation to Loop by Number of Data operation, the process is repeated as many times as the number of files and directories obtained.
- In Loop by Number of Data operation, check whether or not a specific string is included in the file names by the following conditions in Conditional Branch operation.
・[contain]: a specific string
・[end with]: ".csv" - Execute Read CSV Files operation in the processing when the condition is met.
*It is possible to use the name of the file stored in the script variable in step 2 as the file name specified.
For details of each logic, please refer to the following pages.
Get List of File Names
https://www.hulft.com/help/en-us/HULFTSquare/Content/Designer/Connector/file_list_file.htm
Assign Variables
https://www.hulft.com/help/en-us/HULFTSquare/Content/Designer/Mapper/mpp_detail.htm
Loop by Number of Data
https://www.hulft.com/help/en-us/HULFTSquare/Content/Designer/Connector/flow_loop_by_number_of_data.htm
Conditional Branch
https://www.hulft.com/help/en-us/HULFTSquare/Content/Designer/Connector/flow_conditional_branch.htm
Comments
0 comments
Article is closed for comments.