сделай так чтобы я писал путь в консоль например "C:\Users\Admin\Downloads\AyuGram Desktop\ChatExport_2024-11-17\result.json" а он работал вот код : # -*- coding: utf-8 -*-
import csv
import json
import argparse
from datetime import datetime

def timestamp():
    return datetime.now().strftime("%Y-%m-%d_%H-%M-%S")

class TelegramChatParser:
    def __init__(self):
        self.columns = [
            "msg_id", "sender", "sender_id", "reply_to_msg_id",
            "date", "date_unixtime", "msg_type", "msg_content",
            "forwarded_from", "action", "has_mention",
            "has_email", "has_phone", "has_hashtag", "is_bot_command",
        ]
        self.file_types = {"animation", "video_file", "video_message", "voice_message", "audio_file"}
        self.mention_types = {"mention", "mention_name"}

    def process_message(self, message):
        if message.get("type") != "message":
            return None

        row = {
            "msg_id": message.get("id"),
            "sender": message.get("from"),
            "sender_id": message.get("from_id"),
            "reply_to_msg_id": message.get("reply_to_message_id", ""),
            "date": message.get("date"),
            "date_unixtime": message.get("date_unixtime"),
            "msg_type": "text",
            "msg_content": message.get("text", "").replace("\n", " "),
            "forwarded_from": message.get("forwarded_from", ""),
            "action": message.get("action", ""),
            "has_mention": 0,
            "has_email": 0,
            "has_phone": 0,
            "has_hashtag": 0,
            "is_bot_command": 0,
        }

        if "media_type" in message:
            row["msg_type"] = message["media_type"]
            if message["media_type"] == "sticker":
                row["msg_content"] = message.get("file", "?")
            elif message["media_type"] in self.file_types:
                row["msg_content"] = message.get("file", "")
        elif "file" in message:
            row["msg_type"] = "file"
            row["msg_content"] = message["file"]
        elif "photo" in message:
            row["msg_type"] = "photo"
            row["msg_content"] = message["photo"]
        elif "poll" in message:
            row["msg_type"] = "poll"
            row["msg_content"] = str(message["poll"].get("total_voters", 0))
        elif "location_information" in message:
            loc = message["location_information"]
            row["msg_type"] = "location"
            row["msg_content"] = f"{loc['latitude']},{loc['longitude']}"

        content = message.get("text", "")
        if isinstance(content, list):
            txt = ""
            for part in content:
                if isinstance(part, dict):
                    p_type = part.get("type")
                    if p_type in self.mention_types:
                        row["has_mention"] = 1
                    elif p_type == "email":
                        row["has_email"] = 1
                    elif p_type == "phone":
                        row["has_phone"] = 1
                    elif p_type == "hashtag":
                        row["has_hashtag"] = 1
                    elif p_type == "bot_command":
                        row["is_bot_command"] = 1
                    if p_type == "link":
                        row["msg_type"] = "link"
                    txt += part.get("text", "")
                else:
                    txt += part
            row["msg_content"] = txt.replace("\n", " ")

        return row

    def process_chat(self, chat):
        return {
            "chat": chat.get("name", "Безымянный Чат"),
            "rows": [self.process_message(msg) for msg in chat.get("messages", []) if self.process_message(msg)]
        }

    def process(self, filepath):
        try:
            with open(filepath, "r", encoding="utf-8-sig") as f:
                data = json.load(f)
        except FileNotFoundError:
            print(f"Ошибка: Файл '{filepath}' не найден.")
            sys.exit(1)
        except json.JSONDecodeError:
            print(f"Ошибка: Файл '{filepath}' не является корректным JSON.")
            sys.exit(1)
        
        chats = data.get("chats", {}).get("list") or data.get("left_chats", {}).get("list") or [data]
        return [self.process_chat(chat) for chat in chats]

    def to_csv(self, data, include_timestamp=False):
        for dump in data:
            filename = f"{dump['chat']}.csv"
            if include_timestamp:
                filename = f"{timestamp()}_{filename}"
            with open(filename, "w", encoding="utf-8-sig", newline="") as f:
                writer = csv.DictWriter(f, self.columns, quoting=csv.QUOTE_NONNUMERIC)
                writer.writeheader()
                writer.writerows(dump["rows"])

if __name__ == "__main__":
    import os
    import sys

    parser = argparse.ArgumentParser(
        description="Скрипт для преобразования истории чата Telegram из JSON в CSV.",
        usage="python3 telegrama_chat_parser.py <путь_к_result.json> [-o]",
        epilog="Сообщения об ошибках принимаются на https://github.com/keizerzilla/telegram-chat-parser/issues"
    )
    
    # Обязательный аргумент: путь к JSON-файлу
    parser.add_argument("json_path", help="Путь к файлу 'result.json', экспортированному из Telegram.")
    
    # Необязательный флаг для добавления временной метки к имени файла
    parser.add_argument("-o", "--output", action="store_true", help="Включить временную метку в имени выходного файла.")
    
    args = parser.parse_args()

    # Проверка существования файла
    if not os.path.isfile(args.json_path):
        print(f"Ошибка: Файл по пути '{args.json_path}' не существует.")
        sys.exit(1)

    # Создание экземпляра парсера и обработка данных
    parser_instance = TelegramChatParser()
    parsed_data = parser_instance.process(args.json_path)
    parser_instance.to_csv(parsed_data, include_timestamp=args.output)