Subject: Prompt With List Limited to 20 Items? Assistance Needed with CSV Data Import
Hello Keyboard Maestro Community,
I’m working on a macro that reads data from a CSV file and uses the “Prompt With List” action to display a list of authors for selection. However, I’ve encountered an issue where only the first 20 entries from the CSV file are displayed in the prompt, even though the CSV file contains more than 20 entries.
Here’s what I’m trying to achieve:
• Read a CSV file (authors.csv) containing author information.
• Generate a list of authors, where each list item includes display information and all author data, separated by unique delimiters.
• Use “Prompt With List” to allow the user to select an author from the generated list.
• Parse the selected entry to extract individual author data fields for use in automating data entry tasks.
The Issue:
• When the CSV file has more than 20 entries, only the first 20 entries appear in the “Prompt With List” dialog.
• If I insert a new entry into the CSV file at a position between rows 1-20, the new entry shows up, but the entry that moves to position 21 is no longer displayed.
• Executing the shell script directly in the macro or using debugging actions confirms that only 20 lines are being processed and output.
What I’ve Tried:
- Original Shell Script:
#!/bin/bash
csvFilePath="/path/to/authors.csv"
# Check if the file exists
if [ ! -f "$csvFilePath" ]; then
>&2 echo "CSV file not found at path: $csvFilePath"
exit 1
fi
# Read the CSV file and skip the header
tail -n +2 "$csvFilePath" | while IFS=, read -r AuthorID FirstName MiddleInitial LastName Email Credentials; do
# Construct display name
if [ -n "$MiddleInitial" ]; then
DisplayName="$FirstName $MiddleInitial. $LastName [$AuthorID]"
else
DisplayName="$FirstName $LastName [$AuthorID]"
fi
# Create a line with display name and all data, separated by a unique delimiter
echo "$DisplayName|||$AuthorID|$FirstName|$MiddleInitial|$LastName|$Email|$Credentials"
done
- Modified Shell Script (Avoiding Piping):
#!/bin/bash
csvFilePath="/path/to/authors.csv"
# Check if the file exists
if [ ! -f "$csvFilePath" ]; then
>&2 echo "CSV file not found at path: $csvFilePath"
exit 1
fi
# Read the CSV file, skip the header, and process each line
{
# Read and discard the header line
IFS= read -r header
# Process each line
while IFS=, read -r AuthorID FirstName MiddleInitial LastName Email Credentials; do
# Construct display name
if [ -n "$MiddleInitial" ]; then
DisplayName="$FirstName $MiddleInitial. $LastName [$AuthorID]"
else
DisplayName="$FirstName $LastName [$AuthorID]"
fi
# Create a line with display name and all data, separated by a unique delimiter
echo "$DisplayName|||$AuthorID|$FirstName|$MiddleInitial|$LastName|$Email|$Credentials"
done
} < "$csvFilePath"
- Debugging Attempts:
• Added “Display Text” actions to show the contents of the AuthorList variable.
• Confirmed that only 20 lines are output, matching the behavior of the “Prompt With List” action.
• Verified that edits to entries within the first 20 lines are reflected, but any entries beyond line 20 are not processed or displayed.
Observations:
• It seems like there might be a limit of 20 items for the “Prompt With List” action or perhaps within the shell script processing in Keyboard Maestro.
• The CSV file is properly formatted, and the file path is correct.
• When running the shell script independently in Terminal, all entries are processed and displayed correctly.
CSV File Example (Simplified):
AuthorID,FirstName,MiddleInitial,LastName,Email,Credentials
Author1,First1,,Last1,email1@example.com,Credentials1
Author2,First2,,Last2,email2@example.com,Credentials2
...
Author21,First21,,Last21,email21@example.com,Credentials21
Questions:
-
The limit to the number of items that can be processed or displayed in the “Prompt With List” action is 99, correct?
-
Is there a limitation within Keyboard Maestro’s shell script processing that could be causing only the first 20 lines to be read?
-
Are there alternative approaches to process and display more than 20 items from a CSV file within Keyboard Maestro?
Additional Details:
• I’m using Keyboard Maestro version Version 11.0.3 on macOS Seqoia 15.0.
• The macro works perfectly with 20 or fewer entries.
• The issue persists even after restarting Keyboard Maestro and the macOS system.
Any assistance or suggestions would be greatly appreciated!
Thank you in advance for your help.