ImportText
The ImportText() function retrieves data from an external text file. It allows users to import specific columns that meet user-defined criteria.
Related functions: ImportCSV, ImportExcel, ImportODBC
Syntax:
Qx.ImportText(File, [Delimiter], [Filter Expression], [Columns])- In Excel with Quintessence addin versions prior to 25.1, use:
ImportText() - In the Quintessence Editor (Studio) using Quintessence language, use:
ImportText() - In the Quintessence Editor (Studio) using Python language, use:
Qx.ImportText()
ⓘ See parameter descriptions
| File | The path to the CSV file to import. |
| Delimiter (optional) | The character that separates columns in the text file. |
| Filter Expression (optional) | The expression representing the filter criteria to apply to the data. |
| Columns (optional) | The columns to return, represented as Cn. By default, columns are imported as text. The format can be changed using the following options:• Convert column to number: Cn:N• Convert column to date: Cn:D• Convert column to text: Cn:T |
Remarks:
- Unless changed by an administrator, the default parameters are:
- Delimiter: No delimiter applied.
- Filter Expression: No filter is applied to the imported data.
- Columns:
*(all columns are imported).
Examples:
The examples provided below are based on fictitious data for illustrative purposes only.
> Example 1: Import data that meets a criterion and output specific columns
Assume the text file is located at:
C:\Quintessence\ExcelPing.txtFile contents:
Name, Value, Year
Person_1, 100, 2000-01-01
Person_2, 200, 5 Jan 2020
Person_3, 300, 2000-01-01
The goal is to return all rows where the second column contains a value greater than or equal to 200, ensuring:
- Column 2 is numeric
- Column 3 is in date format
- Headers are excluded
Formula:
=Qx.ImportText("C:\Quintessence\ExcelPing.txt", ",", "Line > 1 & C2 >= 200", "C1, C2:N, C3:D")Result:
| Person_2 | 200 | 2020/01/05 |
| Person_3 | 300 | 2000/01/01 |
