# **CarQuery**
CarQuery is a Python library that enables you to effortlessly gather comprehensive car model data from the Car Query API and export it into a CSV format. With robust filtering capabilities, you can refine your search based on manufacturer, model, variant, production year, and more. Dive into the world of automotive data with ease and flexibility!
---
## **Features**
- **Comprehensive Data**: Fetch detailed car model information from the Car Query API.
- **Flexible Filtering**: Refine your search by specifying:
- Manufacturer
- Model
- Variant
- Production year range
- Whether the car is sold in the US
- **Exclusion Words**: Exclude specific words from variant names to tailor your results.
- **Export to CSV**: Save filtered data to a CSV file for further analysis and visualization.
---
## **Installation**
You can install CarQuery directly from PyPI:
```bash
pip install carquery
```
---
## **Usage**
Here’s how you can use the library in your Python projects.
### **Import the Library**
```python
from carquery import fetch_models, fetch_car_data, write_to_csv, print_table
```
### **Fetching Models**
To fetch all models for a specific manufacturer:
```python
make = "Honda"
models = fetch_models(make)
print("Available Models:")
print_table(models)
```
---
### **Fetching Car Data**
You can fetch detailed car data using various filters:
```python
make = "Honda"
model = "Civic" # Leave empty for all models
variant = "" # Leave empty for all variants
from_year = 2010
to_year = 2022
sold_in_us = True # Set to True, False, or None for all
car_data = fetch_car_data(make=make, model=model, variant=variant, from_year=from_year, to_year=to_year, sold_in_us=sold_in_us)
print(f"Fetched {len(car_data)} car entries.")
```
---
### **Exporting to CSV**
You can export the fetched data to a CSV file for further analysis:
```python
filename = f"{make}_{model}_car_data.csv"
write_to_csv(filename, car_data)
print(f"Data has been saved to {filename}")
```
---
### **Excluding Specific Words from Variants**
You can filter out variants containing specific words by processing the `car_data` list before exporting:
```python
exclusion_words = ["Touring", "Sport"]
filtered_car_data = [
entry for entry in car_data
if not any(word.lower() in entry['vehicle_variant'].lower() for word in exclusion_words)
]
filename = f"{make}_{model}_filtered_car_data.csv"
write_to_csv(filename, filtered_car_data)
print(f"Filtered data has been saved to {filename}")
```
---
## **Example: Full Workflow**
Here’s a complete example that uses all features:
```python
from carquery import fetch_models, fetch_car_data, write_to_csv, print_table
# Fetch models for a manufacturer
make = "Honda"
models = fetch_models(make)
print("Available Models:")
print_table(models)
# Fetch detailed car data
model = "Civic"
car_data = fetch_car_data(make=make, model=model, from_year=2010, to_year=2022, sold_in_us=True)
print(f"Fetched {len(car_data)} car entries.")
# Exclude specific words from variants
exclusion_words = ["Touring", "Sport"]
filtered_car_data = [
entry for entry in car_data
if not any(word.lower() in entry['vehicle_variant'].lower() for word in exclusion_words)
]
# Save to CSV
filename = f"{make}_{model}_filtered_car_data.csv"
write_to_csv(filename, filtered_car_data)
print(f"Filtered data has been saved to {filename}")
```
---
## **Dependencies**
This library requires the following Python packages:
- `requests`
- `prettytable`
- `tqdm`
These will be automatically installed when you install the library via `pip`.
---
## **Contributing**
Contributions are welcome! Please follow these steps:
1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Submit a pull request explaining your changes.
---
## **License**
This library is distributed under the MIT License. See the `LICENSE` file for more details.
---
## **Support**
If you encounter any issues or have questions, feel free to open an issue on the [GitHub repository](https://github.com/Salman0x01/Car-Model-Data-Scraper/tree/main).
Raw data
{
"_id": null,
"home_page": "https://github.com/Salman0x01/Car-Model-Data-Scraper/tree/main",
"name": "carquery",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Salman Khan",
"author_email": "salman@sprotechs.com",
"download_url": "https://files.pythonhosted.org/packages/2f/9e/4b4e112350c6f091a7077fb9f941aa8a6e0a870a04d8c4ddee8da0239ef8/carquery-0.1.0.tar.gz",
"platform": null,
"description": "# **CarQuery**\n\nCarQuery is a Python library that enables you to effortlessly gather comprehensive car model data from the Car Query API and export it into a CSV format. With robust filtering capabilities, you can refine your search based on manufacturer, model, variant, production year, and more. Dive into the world of automotive data with ease and flexibility!\n\n---\n\n## **Features**\n\n- **Comprehensive Data**: Fetch detailed car model information from the Car Query API.\n- **Flexible Filtering**: Refine your search by specifying:\n - Manufacturer\n - Model\n - Variant\n - Production year range\n - Whether the car is sold in the US\n- **Exclusion Words**: Exclude specific words from variant names to tailor your results.\n- **Export to CSV**: Save filtered data to a CSV file for further analysis and visualization.\n\n---\n\n## **Installation**\n\nYou can install CarQuery directly from PyPI:\n\n```bash\npip install carquery\n```\n\n---\n\n## **Usage**\n\nHere\u2019s how you can use the library in your Python projects.\n\n### **Import the Library**\n\n```python\nfrom carquery import fetch_models, fetch_car_data, write_to_csv, print_table\n```\n\n### **Fetching Models**\n\nTo fetch all models for a specific manufacturer:\n\n```python\nmake = \"Honda\"\nmodels = fetch_models(make)\nprint(\"Available Models:\")\nprint_table(models)\n```\n\n---\n\n### **Fetching Car Data**\n\nYou can fetch detailed car data using various filters:\n\n```python\nmake = \"Honda\"\nmodel = \"Civic\" # Leave empty for all models\nvariant = \"\" # Leave empty for all variants\nfrom_year = 2010\nto_year = 2022\nsold_in_us = True # Set to True, False, or None for all\n\ncar_data = fetch_car_data(make=make, model=model, variant=variant, from_year=from_year, to_year=to_year, sold_in_us=sold_in_us)\nprint(f\"Fetched {len(car_data)} car entries.\")\n```\n\n---\n\n### **Exporting to CSV**\n\nYou can export the fetched data to a CSV file for further analysis:\n\n```python\nfilename = f\"{make}_{model}_car_data.csv\"\nwrite_to_csv(filename, car_data)\nprint(f\"Data has been saved to {filename}\")\n```\n\n---\n\n### **Excluding Specific Words from Variants**\n\nYou can filter out variants containing specific words by processing the `car_data` list before exporting:\n\n```python\nexclusion_words = [\"Touring\", \"Sport\"]\n\nfiltered_car_data = [\n entry for entry in car_data\n if not any(word.lower() in entry['vehicle_variant'].lower() for word in exclusion_words)\n]\n\nfilename = f\"{make}_{model}_filtered_car_data.csv\"\nwrite_to_csv(filename, filtered_car_data)\nprint(f\"Filtered data has been saved to {filename}\")\n```\n\n---\n\n## **Example: Full Workflow**\n\nHere\u2019s a complete example that uses all features:\n\n```python\nfrom carquery import fetch_models, fetch_car_data, write_to_csv, print_table\n\n# Fetch models for a manufacturer\nmake = \"Honda\"\nmodels = fetch_models(make)\nprint(\"Available Models:\")\nprint_table(models)\n\n# Fetch detailed car data\nmodel = \"Civic\"\ncar_data = fetch_car_data(make=make, model=model, from_year=2010, to_year=2022, sold_in_us=True)\nprint(f\"Fetched {len(car_data)} car entries.\")\n\n# Exclude specific words from variants\nexclusion_words = [\"Touring\", \"Sport\"]\nfiltered_car_data = [\n entry for entry in car_data\n if not any(word.lower() in entry['vehicle_variant'].lower() for word in exclusion_words)\n]\n\n# Save to CSV\nfilename = f\"{make}_{model}_filtered_car_data.csv\"\nwrite_to_csv(filename, filtered_car_data)\nprint(f\"Filtered data has been saved to {filename}\")\n```\n\n---\n\n## **Dependencies**\n\nThis library requires the following Python packages:\n\n- `requests`\n- `prettytable`\n- `tqdm`\n\nThese will be automatically installed when you install the library via `pip`.\n\n---\n\n## **Contributing**\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Submit a pull request explaining your changes.\n\n---\n\n## **License**\n\nThis library is distributed under the MIT License. See the `LICENSE` file for more details.\n\n---\n\n## **Support**\n\nIf you encounter any issues or have questions, feel free to open an issue on the [GitHub repository](https://github.com/Salman0x01/Car-Model-Data-Scraper/tree/main).\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library for fetching car data from CarQueryAPI",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/Salman0x01/Car-Model-Data-Scraper/tree/main"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f5b977291406ca8a1da68b03fefc0d96d245bd11785fa376b9822fbd2e7cfb45",
"md5": "1054ec1e8a5fe116024f416a24beff8a",
"sha256": "8833aaff875098a08559472ccb00241f029d93115d80557ff6bee3a7b4d44138"
},
"downloads": -1,
"filename": "carquery-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1054ec1e8a5fe116024f416a24beff8a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 4585,
"upload_time": "2024-12-21T19:29:06",
"upload_time_iso_8601": "2024-12-21T19:29:06.714110Z",
"url": "https://files.pythonhosted.org/packages/f5/b9/77291406ca8a1da68b03fefc0d96d245bd11785fa376b9822fbd2e7cfb45/carquery-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2f9e4b4e112350c6f091a7077fb9f941aa8a6e0a870a04d8c4ddee8da0239ef8",
"md5": "c5337e60598a1c996cc4b68e039acecb",
"sha256": "4749b19dd35664090870b11ec426e8b8a99981f1031b7da76d2cdcdb4b6c9142"
},
"downloads": -1,
"filename": "carquery-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "c5337e60598a1c996cc4b68e039acecb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4250,
"upload_time": "2024-12-21T19:29:08",
"upload_time_iso_8601": "2024-12-21T19:29:08.894260Z",
"url": "https://files.pythonhosted.org/packages/2f/9e/4b4e112350c6f091a7077fb9f941aa8a6e0a870a04d8c4ddee8da0239ef8/carquery-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-21 19:29:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Salman0x01",
"github_project": "Car-Model-Data-Scraper",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": []
},
{
"name": "prettytable",
"specs": []
},
{
"name": "tqdm",
"specs": []
},
{
"name": "csv",
"specs": []
}
],
"lcname": "carquery"
}