• Font Size
  • S
  • M
  • L
  • Top Category > General Questions > DataSpider Servista > [DataSpider Servista] There are files with multiple extensions such as .log and .bat in a single directory. I want to read only the file with the extension .csv from the directory. Is there a good w

Search via FAQ No.


  • No : 30538
  • Open Date : 2019/09/05 16:01
  • Print
NEW

[DataSpider Servista] There are files with multiple extensions such as .log and .bat in a single directory. I want to read only the file with the extension .csv from the directory. Is there a good w

A single directory contains files with multiple extensions, such as .log and .bat. I want to read only the file with the extension .csv among these files. Is there a good way to do this?
Category : 

Answer

It is possible to read all the csv files with a specific character string that exist within a folder by checking whether the file name acquired in the Get List of File Names process contains a specific character string using the Conditional Branch process in the Loop by Number of Data process.

■Procedure

  1. Acquire the name of a file or a directory within the directory using the [Get List of File Names] process and output the name of the file or the directory that was obtained using [file] - [name] of the output schema.
  2. Using [Variable Mapper], please store the above [file]-[name] of the output schema into a string type script variable.
  3. Repeat the process for as many files and directories that were retrieved by passing the results of [Get List of File Names] to [Loop by Number of Data].
  4. Within the [Loop by Number of Data)], check whether the name of the file contains a specific string using the following conditions in [Conditional Branch]:

[contain]: The value is a specific string
[end with]: The value is ".csv"

  1. Execute [Read CSV File] as a part of the action taken when the condition is met.

It is possible to reuse the name of the file stored in the above string type script variable as the file name.

Please refer to the following DataSpider Servista Help for detail about each logic.

  • [File operation]-[ Get List of File Names]

URL:https://www.hulft.com/help/en-us/DataSpider/dss42sp2/help/en/adapter/file/file_list_file.html

  • [Basic]-[Process]-[Assign Variables]

   URL:https://www.hulft.com/help/en-us/DataSpider/dss42sp2/help/en/mapper/mapper.html

  • [Basic]-[Flow]-[ Loop by Number of Data]

   URL:https://www.hulft.com/help/en-us/DataSpider/dss42sp2/help/en/adapter/basic/foreach.html

  • [Basic]-[Flow]-[Conditional Branch]

   URL:https://www.hulft.com/help/en-us/DataSpider/dss42sp2/help/en/adapter/basic/condition.html

 
Version Information
Ver.4.1、Ver.4.0、Ver.3.2