Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object. We will be deleting a “Test.txt” source file which exists within a folder.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\DeleteFile\Test.txt
Right-click on the function transformation object and select Preview Output. While the Data Preview will not generate an output, the existing file within the specified location will be deleted.
Name
DeleteFile
Syntax
DeleteFile (String filePath)
Purpose
To delete a file if it exists.
Description
Deletes a file if exists.
Return Type
Void
Parameter
filePath [System.String] – Full path of the file.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object. We will be checking for an existing directory.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned the Boolean value “True”, as this directory does exist.
Name
DirectoryExists
Syntax
DirectoryExists (String filePath)
Purpose
To check and return either ‘True’ or ‘False’ depending on whether a specified directory exists.
Description
Checks whether a directory exists.
Return Type
Boolean
Parameter
filePath [System.String] – Path of the directory to check.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object. We will be checking for an existing file.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\File Exists\FileExists.docx
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned the Boolean value “True”, as this file does exist.
Name
FileExists
Syntax
FileExists (String filePath)
Purpose
To check and return either ‘True’ or ‘False’ depending on whether a specified file exists.
Description
Checks whether a file exists.
Return Type
Boolean
Parameter
filePath [System.String] – Path of the file to check.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object. We will be appending the string, “HELLO WORLD”, into an empty ‘Test’ .txt file.
Where,
str = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Test.txt
text = HELLO WORLD
Right-click on the function transformation object and select Preview Output. While the Data Preview will not generate an output. Upon opening the file for which the path was defined earlier, you will see that Astera Data Stack has appended the provided string value into this file.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Documentation Projects\Functions Documentation\Files\FileLineCount\Test.txt
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has returned the number of lines in the specified file, as evident below:
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\GetDirectory\GetDirectory.docx
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has extracted the directory of the specified file.
Name
AppendTextToFile
Syntax
AppendTextToFile (String filePath, String text)
Purpose
To append string to a file.
Description
Appends string to a file. Creates a new file if it does not exist.
Return Type
Void
Parameters
filePath [System.String] – Full path of the file
text [System.String] – Text to be appended to the file
Name
FileLineCount
Syntax
FileLineCount (String filePath)
Purpose
To return the number of lines in a file.
Description
Returns the number of lines in a specified file.
Return Type
Int64
Parameter
filePath [System.String] – Path of the source file
Name | GetDirectory |
Syntax | GetDirectory (String filePath) |
Purpose | To return the directory of a file, specified using a file path. |
Description | Extracts directory path from the given file path. |
Return Type | Int64 |
Parameter | filePath [System.String] – Full path of the file |
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object. We will be copying a “Test.txt” source file to a different destination file folder.
Where,
sourceFilePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\AppendTextToFile\Test.txt
destFilePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\CopyFile\Test3.txt
overWrite = False
Right-click on the function transformation object and select Preview Output. While the Data Preview will not generate an output. Upon opening destination file location, you can see that Astera Data Stack has copied the Test.txt file, with the specified name, Test3.txt.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\sampledata
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned the specified EDI file’s meta-data.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\FileLength\Test.txt
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has returned the number of bytes in the specified file, as evident below:
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\GetFileNameWithoutExtension\GetFileNameWithoutExtension.docx
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned the file name without extension of the specified file path.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\LastUpdateDateTime\LastUpdateDateTime.docx
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has returned the datetime value of when the specified file was last updated.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object. We will be defining the file path of the file for which we want to extract the extension.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\GetFileExtension\GetFileExtension.docx
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned the extracted file extension from the specified file path.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object. We will be checking for worksheets in an Excel file.
Where,
excelFilePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Test.xlsx
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned a list of all the worksheet present in the Excel workbook, for which the path was specified.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\GetFileInfo\GetFileInfo.docx
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned all file properties of the specified file.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\CreateDateTime\Test.txt
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has returned the datetime value of when he specified file was created, as evident below:
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\GetFileName\GetFileName.docx
Right-click on the function transformation object and select Preview Output. As you can see, Astera Data Stack has returned the file name of the specified file path.
Name
CopyFile
Syntax
CopyFile (String sourceFilePath, String destFilePath, Boolean overWrite)
Purpose
To copy a file to a specified destination file.
Description
Copies a file to the specified destination file.
Return Type
Void
Parameters
sourceFilePath [System.String] – Full path of the source file
destFilePath [System.String] – Full path of the destination file
overwrite [System.Boolean] – Indicates whether the existing file should be overwritten
Name
GetEDIFileMetaData
Syntax
GetEDIFileMetaData (String filePath)
Purpose
To read the first line of text of an EDI file and return the meta-data.
Description
Returns meta-data including the dialect, version, and message type.
Return Type
EdiMetaProperties
Syntax
filePath [System.String] – Full path of the file.
Name
FileLength
Syntax
FileLength (String filePath)
Purpose
To return length of the specified file.
Description
Returns the number of bytes in a specified file.
Return Type
Int64
Parameter
filePath [System.String] – Path of the source file
Name
GetFileNameWithoutExtension
Syntax
GetFileNameWithoutExtension (String filePath)
Purpose
To return file name without extension from the given file path.
Description
Extracts file name without extension from the given file path.
Return Type
String
Parameter
filePath [System.String] – Full path of the file.
Name
LastUpdateDateTime
Syntax
LastUpdateDateTime (String filePath)
Purpose
To return the last update date time value for the specified file.
Description
Returns last update date time for a file.
Return Type
DateTime
Parameter
filePath [System.String] – Path of the source file
Name
GetFileExtension
Syntax
GetFileExtension (String filePath)
Purpose
To return file extension from the specified file path.
Description
Extracts file extension from the given file path.
Return Type
String
Parameter
filePath [System.String] – Full path of the file to check.
Name
GetExcelWorksheets
Syntax
GetExcelWorksheets (String excelFilePath)
Purpose
To enumerate and return names of Worksheets from an Excel file.
Description
Enumerates names of all the worksheets in the Excel workbook.
Return Type
List
Parameters
excelFilePath [System.String] – Full path of the Excel workbook.
Name | GetFileInfo |
Syntax | GetFileInfo (String filePath) |
Purpose | To return informationabout the specified file. |
Description | Returns information about a file. |
Return Type | FileProperties |
Parameter | filePath [System.String] – Path of the file. |
Name | CreateDateTime |
Syntax | CreateDateTime (String filePath) |
Purpose | To return date time value of when a specified file was created. |
Description | Returns create date time for a specified file. |
Return Type | DateTime |
Parameter | filePath [System.String] – Path of the source file |
Name | GetFileName |
Syntax | GetFileName (String filePath) |
Purpose | To return file name from the given file path. |
Description | Extracts file name from the given file path. |
Return Type | String |
Parameter | filePath [System.String] – Full path of the file. |
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\ReadFileFirstLine\Test.txt
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has returned the first line of the specified file.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Documentation Projects\Functions Documentation\Files\ReadFileText-codePage\Test.txt
codepage = 65001 (UTF-8 Unicode)
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has returned the entire text of the specified file.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object. We will be moving a “Test.xlsx” source file to a different destination file folder.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Test.xlsx
newFilePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\TestFileMove
Right-click on the function transformation object and select Preview Output. While the Data Preview will not generate an output. Upon opening the destination file location, you can see that Astera Data Stack has moved the Test.xlsx file to the specified folder.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object and a ToBytes function transformation object. We will be writing the byte array, “48656C6C6F20576F726C64”, into a new, empty Test.txt file.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Test.txt
bytes = 48656C6C6F20576F726C64
Right-click on the function transformation object and select Preview Output. While the Data Preview will not generate an output, a new file with the specfied name will be created at the specified loaction, and the provided byte array will be written to this file, after being converted into a string value.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\ReadFileBytes\Test.txt
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has read and returned the bytes of the specified file.
Example
In this example, we are passing the required parameters to the function transformation object using a Variables object. We will be writing the string, “HELLO WORLD 123”, into a new, empty ‘TEST_WRITE’ .txt file.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\TEST_WRITE.txt
text = HELLO WORLD 123
Right-click on the function transformation object and select Preview Output. While the Data Preview will not generate an output, a new file with the specfied name will be created in the specified loaction, and the provided text will be written to this file.
Example
In this example, we are passing the required parameter to the function transformation object using a Variables object.
Where,
filePath = C:\Users\Kanwal.Azim\OneDrive - Astera Software\Desktop\Functions Documentation\Files\ReadFileText\Test.txt
Right-click on the function transformation object and select Preview Output. You can see that Astera Data Stack has returned the entire text of the specified file.
Name
ReadFileFirstLine
Syntax
ReadFileFirstLine (String filePath)
Purpose
To read and return contents of the file up until the first line.
Description
Reads the first line of text of the specified file and returns the text.
Return Type
String
Parameter
filePath [System.String] – Full path of the file
Name
ReadFileText
Syntax
ReadFileText (String filePath, String codePage)
Purpose
To read and return all contents of the file.
Description
Reads the entire text of the file and returns the text, considering the provided codePage string. Use this function only for very small files.
Return Type
String
Parameter
filePath [System.String] – Full path of the file
codepage [System.String] – Code page of the encoding to use
Name
MoveFile
Syntax
MoveFile (String filePath, String newDirectory)
Purpose
To move a file to a specified destination Directory.
Description
Moves a file to the specified destination directory, if it exists.
Return Type
Void
Parameters
filePath [System.String] – Full path of the file
newFilePath [System.String] – New directory path
Name
WriteBytesToFile
Syntax
WriteBytesToFile (String filePath, ByteArray bytes)
Purpose
To write bytes to a file.
Description
Writes bytes to a file. Creates a new file and overwrites the file if it already exists.
Return Type
Void
Parameters
filePath [System.String] – Full path of the file
bytes [System.Byte[]] – A byte array to be written to the file
Name
ReadFileBytes
Syntax
ReadFileBytes (String filePath)
Purpose
To read and return entire contents of the specified file in bytes.
Description
Reads all bytes of the file and returns a byte array containing all of the file’s contents. Use this function only for small binary files.
Return Type
Byte
Parameter
filePath [System.String] – Full path of the file
Name
WriteTextToFile
Syntax
WriteTextToFile (String filePath, String text)
Purpose
To write a string to a file.
Description
Writes string to a file. Creates a new file if it does not exist.
Return Type
Void
Parameters
filePath [System.String] – Full path of the file
text [System.String] – Text to be written to the file
Name
ReadFileText
Syntax
ReadFileText (String filePath)
Purpose
To read and return all contents of the file.
Description
Reads the entire text of the file and returns the text. Use this function only for very small files.
Return Type
String
Parameter
filePath [System.String] – Full path of the file