Filesystem Service

The filesystem service provides read and write access to a virtualized filesystem provided by Personalization. The filesystem contains the SFTP directories where feed files are uploaded. These files can be accessed by any Gear component that includes the filesystem service such as ETL.

Writing files is accomplished by calling filesystem.writeFile("/path/filename"), which returns a FileWriter pointing to the specified file. If the file exists, it is overwritten unless the append parameter is set to true as in filesystem.writeFile("/path/filename", true).

Example

Similarly, calls to filesystem.readFile("/path/filename") returns a FileLineReader. Lines can then be iterated over by calling hasNext() and readLine() on the FileLineReader. Wrappers are provided for parsing CSV and XML file formats.

CSV

To parse a CSV file and obtain a record iterator use context.services.csv.readFile("/path/filename"), which returns a CsvReader. The CsvReader is especially useful when writing jobs that return a record iterator from their extract phase such as ETL.

XML

The XML wrapper works in the same way. Calling context.services.xml.readFile("/path/filename") returns an XmlReader.

Example