Clear Symbols();
// Open a file dialog to choose the text file
txtFilePath = Pick File("Choose a text file", {"Text Files|*.txt"});
// Check if a file was selected
If(txtFilePath != "",
// Convert the file path to ensure it's in the correct format
txtFilePath = Convert File Path(txtFilePath);
// Import the text file into a new JMP table
dt1 = Open(
txtFilePath,
Delimiter("\t") // Change delimiter if necessary
);
// Specify the row to use for column names (e.g., row 1)
columnNamesRow = 16;
// Specify the columns to extract (e.g., columns 1, 2, 3)
columnsToExtract = {1, 17, 18, 22}; // Adjust column indices as needed
// Extract the column names from the specified row and columns
columnNamesList = {};
For(j = 1, j <= N Items(columnsToExtract), j++,
colIndex = columnsToExtract[j];
columnNamesList[j] = :Column(colIndex)[columnNamesRow];
);
// Create a new JMP table with the extracted column names
dt2 = New Table("Converted Table");
For(i = 1, i <= N Items(columnNamesList), i++,
dt2 << New Column(Char(columnNamesList[i]), Character); // Adjust column type as needed
);
// Specify the rows to extract (e.g., rows 2 to 10)
startRow = 17;
endRow = 65;
//
// Loop through the specified rows and add them to the JMP table
For(i = startRow, i <= endRow, i++,
dt2 << Add Rows(1);
For(j = 1, j <= N Items(columnsToExtract), j++,
colIndex = columnsToExtract[j];
dt2:Column(j)[i - startRow + 1] = dt1:Column(colIndex)[i];
);
);
// Close the imported table
Close(dt1);
,
// If no file was selected, show a message
Show Message("No file selected.")
);
I am getting a same error messages:
Scoped data table access requires a data table column or variable at row 1 in access or evaluation of 'dt1:Column' , dt1:Column( colIndex ) /*###*/
at line 49