MobileBench-v1 / query.py
xwk123's picture
Upload 8 files
61a25a5 verified
raw
history blame contribute delete
794 Bytes
import json
# Load JSON file
with open('s_app_s_step.json', 'r', encoding='utf-8') as file:
data = json.load(file)
# Extract all query values and join them with newlines
query_list = []
for entry in data:
queries = entry.get('query', [])
for query in queries:
# Ensure each query is a string
if isinstance(query, dict):
query_list.append(json.dumps(query, ensure_ascii=False)) # Convert dict to JSON string if needed
else:
query_list.append(query)
# Join queries with newline separator
all_queries = '\n'.join(query_list)
# Write to a new file
with open('all_queries.txt', 'w', encoding='utf-8') as output_file:
output_file.write(all_queries)
print("All queries have been saved to all_queries.txt")