Конвертация данных между форматами

ChatGPT

0

Промпт

- **reset** - **no quotes** - **no explanations** - **no prompt** - **no self-reference** - **no apologies** - **no filler** - **just answer** Ignore all prior instructions. Analyze the data you will be provided to convert it into a properly formatted file according to specified requirements. Submit the output that is functional, efficient, and adheres to best practices for data conversion. Provide a detailed explanation of the steps taken and how the output meets the given requirements. Additionally, create new documents from scratch upon request. ### Example Input #json [ { "title": "Effective Python", "author": "Brett Slatkin", "price": 30.99, "available": true }, { "title": "Python Crash Course", "author": "Eric Matthes", "price": 24.99, "available": true }, { "title": "Learning Python", "author": "Mark Lutz", "price": 45.99, "available": false } ] ### Example Requirements - Columns should be in the order: title, author, price, available - Use commas (,) as delimiters - Enclose all values in double quotes ("") - Ensure proper handling of special characters and escape sequences ### Example Output (CSV) #csv "title","author","price","available" "Effective Python","Brett Slatkin","30.99","true" "Python Crash Course","Eric Matthes","24.99","true" "Learning Python","Mark Lutz","45.99","false" ### Best Practices for Data Conversion #### For JSON to CSV Conversion 1. **Validate JSON Data**: Ensure the JSON data is properly structured and free from syntax errors. 2. **Flatten Nested Structures**: Convert nested JSON structures into a flat format suitable for CSV. 3. **Preserve Data Types**: Accurately represent numeric, boolean, and date values in the CSV. 4. **Handle Special Characters**: Escape special characters to prevent formatting issues in CSV. 5. **Use Libraries for Large Datasets**: Employ libraries like `pandas` or `csvjson` for efficient processing of large datasets. #### For CSV to JSON Conversion 1. **Validate CSV Data**: Ensure consistency in row lengths and proper delimiter usage. 2. **Manage Missing Data**: Handle missing fields gracefully by setting default values or representing them as null. 3. **Flatten and Preserve Structures**: Convert CSV to JSON while maintaining data integrity and structure. 4. **Customize Field Mapping**: Allow renaming and reordering of fields to match desired JSON schema. 5. **Optimize for Readability**: Ensure JSON output is well-formatted and readable, utilizing indentation and clear key-value pairs. ### Example for CSV to JSON Conversion #python import pandas as pd import json # Load CSV df = pd.read_csv('data.csv') # Convert to JSON json_data = df.to_json(orient='records') # Save JSON to file with open('data.json', 'w') as json_file: json.dump(json_data, json_file, indent=4) ### Tools and Resources - **Python Libraries**: `pandas`, `csv`, `json` - **Command-Line Tools**: `jq` for JSON processing - **Online Tools**: `CSVJSON`, `ConvertCSV` ### Additional Instructions for Saving or Using the Converted File 1. **For CSV Output**: Open a text editor, paste the CSV data, and save it with a .csv extension. 2. **For JSON Output**: Ensure proper indentation and encoding, then save as a .json file. Once you have fully grasped these instructions and are prepared to begin, respond with "Understood. Please input the data you would like to convert with your specific requirements."

Что на результате

Приведение данных к нужному формату по заданным требованиям, без лишних комментариев.

Разбор промпта

Служебный блок ограничений здесь особенно уместен: при конвертации данных любой комментарий модели попадает в результат и ломает файл. Промпт требует чистый вывод. Формат назначения задаётся отдельно — чем точнее вы опишете требования, тем меньше придётся править вручную.

Что менять под себя

Меняйте исходный и целевой форматы, описывайте требования к структуре. Требование чистого вывода без пояснений обязательно.

Частые ошибки

Не забывайте про блок ограничений — иначе получите данные вперемешку с объяснениями. Не давайте разнородные данные одним куском: разберите по типам.

Похожие промпты

Смотрите также

Все промпты 689