| #!/usr/bin/env python3 | |
| """ | |
| Script to generate JSON files with dataset structure similar to nvil.json | |
| """ | |
| import json | |
| import argparse | |
| from pathlib import Path | |
| def generate_json_data(count: int = 10, start_id: int = 1) -> list: | |
| """ | |
| Generate sample JSON data with id, title, and description fields. | |
| Args: | |
| count: Number of records to generate | |
| start_id: Starting ID number | |
| Returns: | |
| List of dictionaries containing the generated data | |
| """ | |
| data = [] | |
| sample_titles = [ | |
| "Dataset {id}", | |
| "Sample Dataset {id}", | |
| "Test Dataset {id}", | |
| "Training Data {id}", | |
| "Validation Set {id}", | |
| "Deep Learning Dataset {id}", | |
| "ML Dataset {id}", | |
| "Computer Vision Data {id}", | |
| ] | |
| sample_descriptions = [ | |
| "This is a sample dataset for testing and demonstration.", | |
| "A test dataset for training machine learning models.", | |
| "Dataset created for validation purposes.", | |
| "Sample data for deep learning experiments.", | |
| "Dataset for educational purposes.", | |
| "A comprehensive dataset for model evaluation.", | |
| "Test dataset with various features.", | |
| "Dataset suitable for data analysis.", | |
| ] | |
| for i in range(count): | |
| record_id = start_id + i | |
| title_template = sample_titles[i % len(sample_titles)] | |
| description = sample_descriptions[i % len(sample_descriptions)] | |
| record = { | |
| "id": str(record_id), | |
| "title": title_template.format(id=record_id), | |
| "description": description | |
| } | |
| data.append(record) | |
| return data | |
| def save_json(data: list, output_path: str) -> None: | |
| """ | |
| Save data to JSON file. | |
| Args: | |
| data: List of dictionaries to save | |
| output_path: Path where JSON file will be saved | |
| """ | |
| output_file = Path(output_path) | |
| output_file.parent.mkdir(parents=True, exist_ok=True) | |
| with open(output_file, 'w') as f: | |
| json.dump(data, f, indent=4) | |
| print(f"✓ JSON file generated successfully: {output_path}") | |
| print(f" Total records: {len(data)}") | |
| def main(): | |
| parser = argparse.ArgumentParser( | |
| description="Generate JSON files with dataset structure similar to nvil.json" | |
| ) | |
| parser.add_argument( | |
| "-c", "--count", | |
| type=int, | |
| default=10, | |
| help="Number of records to generate (default: 10)" | |
| ) | |
| parser.add_argument( | |
| "-o", "--output", | |
| type=str, | |
| default="dataset/generated_data.json", | |
| help="Output file path (default: dataset/generated_data.json)" | |
| ) | |
| parser.add_argument( | |
| "-s", "--start-id", | |
| type=int, | |
| default=1, | |
| help="Starting ID number (default: 1)" | |
| ) | |
| args = parser.parse_args() | |
| # Generate data | |
| data = generate_json_data(count=args.count, start_id=args.start_id) | |
| # Save to file | |
| save_json(data, args.output) | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 2.98 kB
- Xet hash:
- b80b5333b49fc0f2f3bec804df2f1734f4cff517612dc348d3edb25246d8a2fe
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.