• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

Consistency in Running Python in Pabby Script.

ichilddev

Member
Dear Support & Community.
We have consistency issue running the following script in Pabbly Python.

The script is as such:

import json

def search_preschool(json_data, search_string):
# Parse the JSON data
data = json.loads(json_data)

# Search for the exact string in the 'name' field
for entry in data:
if search_string == entry['name']:
return entry['id'], entry['name']

# If no match is found, return a default message
return "No group found", "No group found"

# Example JSON data
json_data = '''[{"id":"[email protected]","name":"MindChamps@Woodlands"},
{"id":"[email protected]","name":"Brilliant Tots@PotongP"},
{"id":"[email protected]","name":"Carpe Diem@Bukit Batok"},
{"id":"[email protected]","name":"MindChamps@Thomson C"},
{"id":"[email protected]","name":"GUG@Katong V EA"},
{"id":"[email protected]","name":"Red Schhse@Woodleigh NE"},
{"id":"[email protected]","name":"Twinklekidz@Bendemeer"},
{"id":"[email protected]","name":"First Step@Jurong"},
{"id":"[email protected]","name":"Da Little Preschool@Cecil"},
{"id":"[email protected]","name":"ChildFirst@Dunearn EA"},
{"id":"[email protected]","name":"First Step@SK (Initium)"},
{"id":"[email protected]","name":"NurtureStar@Tampines PS"},
{"id":"[email protected]","name":"Safari House"}]'''

# Search string
search_string = "1. GroupName : Blue House Kay Siang HR"

# Call the function
id, name = search_preschool(json_data, search_string)

# Return the results
return id, name

The above results is No group found, No group found

The above works when we use the above exhaustive JSON list.

However when we use the the API to get the JSON list from another application, the attached error is shown.
Kindly advise what is the issue?
 

Attachments

  • This works.jpg
    This works.jpg
    455.9 KB · Views: 33
  • This works - 2.jpg
    This works - 2.jpg
    348.3 KB · Views: 29
  • Getting the JSON from the preceding API works at times.jpg
    Getting the JSON from the preceding API works at times.jpg
    481.1 KB · Views: 25
  • At times will show this error.jpg
    At times will show this error.jpg
    215.3 KB · Views: 29

ichilddev

Member
Dear Support & Community.
We have consistency issue running the following script in Pabbly Python.

The script is as such:

import json

def search_preschool(json_data, search_string):
# Parse the JSON data
data = json.loads(json_data)

# Search for the exact string in the 'name' field
for entry in data:
if search_string == entry['name']:
return entry['id'], entry['name']

# If no match is found, return a default message
return "No group found", "No group found"

# Example JSON data
json_data = '''[{"id":"[email protected]","name":"MindChamps@Woodlands"},
{"id":"[email protected]","name":"Brilliant Tots@PotongP"},
{"id":"[email protected]","name":"Carpe Diem@Bukit Batok"},
{"id":"[email protected]","name":"MindChamps@Thomson C"},
{"id":"[email protected]","name":"GUG@Katong V EA"},
{"id":"[email protected]","name":"Red Schhse@Woodleigh NE"},
{"id":"[email protected]","name":"Twinklekidz@Bendemeer"},
{"id":"[email protected]","name":"First Step@Jurong"},
{"id":"[email protected]","name":"Da Little Preschool@Cecil"},
{"id":"[email protected]","name":"ChildFirst@Dunearn EA"},
{"id":"[email protected]","name":"First Step@SK (Initium)"},
{"id":"[email protected]","name":"NurtureStar@Tampines PS"},
{"id":"[email protected]","name":"Safari House"}]'''

# Search string
search_string = "1. GroupName : Blue House Kay Siang HR"

# Call the function
id, name = search_preschool(json_data, search_string)

# Return the results
return id, name

The above results is No group found, No group found

The above works when we use the above exhaustive JSON list.

However when we use the the API to get the JSON list from another application, the attached error is shown.
Kindly advise what is the issue?

The following has no issue. The code runs and provides the required

import json

def search_preschool(json_data, search_string):
# Parse the JSON data
data = json.loads(json_data)

# Search for the exact string in the 'name' field
for entry in data:
if search_string == entry['name']:
return entry['id'], entry['name']

# If no match is found, return a default message
return "No group found", "No group found"

# Example JSON data line18
json_data = '''[{"id":"noProblem","name":"MindChamps@ C"}]'''

# Search string
search_string = "MindChamps@Thomson C"

# Call the function
id, name = search_preschool(json_data, search_string)

# Return the results
return id, name
 

Attachments

  • result.jpg
    result.jpg
    426.6 KB · Views: 26
  • SCripts Runs.jpg
    SCripts Runs.jpg
    340.7 KB · Views: 27
P

Pabblymember11

Guest
Hey @ichilddev

We have reviewed the code, and corrected several syntax errors, and it is now functioning as expected. Additionally, with OpenAI's assistance, you can generate the code as needed.

1718794240672.png


import json def search_preschool(json_data, search_string): # Parse the JSON data data = json.loads(json_data) # Search for the exact string in the 'name' field for entry in data: if search_string == entry['name']: return entry['id'], entry['name'] # If no match is found, return a default message return "No group found", "No group found" # Example JSON data json_data = '''[{"id":"[email protected]","name":"MindChamps@Woodlands"}, {"id":"[email protected]","name":"Brilliant Tots@PotongP"}, {"id":"[email protected]","name":"Carpe Diem@Bukit Batok"}, {"id":"[email protected]","name":"MindChamps@Thomson C"}, {"id":"[email protected]","name":"GUG@Katong V EA"}, {"id":"[email protected]","name":"Red Schhse@Woodleigh NE"}, {"id":"[email protected]","name":"Twinklekidz@Bendemeer"}, {"id":"[email protected]","name":"First Step@Jurong"}, {"id":"[email protected]","name":"Da Little Preschool@Cecil"}, {"id":"[email protected]","name":"ChildFirst@Dunearn EA"}, {"id":"[email protected]","name":"First Step@SK (Initium)"}, {"id":"[email protected]","name":"NurtureStar@Tampines PS"}, {"id":"[email protected]","name":"Safari House"}]''' # Search string search_string = "1. GroupName : Blue House Kay Siang HR" # Call the function id, name = search_preschool(json_data, search_string) # Print the results print(id, name)
 
Top