filippz / telegram_import

Import back messages exported from Telegram into JSON format
14 stars 2 forks source link

KeyError: 'contact_vcard' #1

Closed ODENYGG closed 2 years ago

ODENYGG commented 2 years ago

Any Help? Newb trying to save a dear person's chat here.

Loading config.ini Loading result.json Converting format Traceback (most recent call last): File "C:\Users\midga\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\indexes\base.py", line 3621, in get_loc return self._engine.get_loc(casted_key) File "pandas_libs\index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\index.pyx", line 163, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas_libs\hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'contact_vcard'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\midga\Desktop\tregret-master\telegram_import.py", line 243, in import_history( File "C:\Users\midga\Desktop\tregret-master\telegram_import.py", line 182, in import_history messages, file_list = convert_to_whatsapp_format(data, only_first_n_messages) File "C:\Users\midga\Desktop\tregret-master\telegram_import.py", line 37, in convert_to_whatsapp_format if not pd.isnull(row["contact_vcard"]): File "C:\Users\midga\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\series.py", line 958, in getitem return self._get_value(key) File "C:\Users\midga\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\series.py", line 1069, in _get_value loc = self.index.get_loc(label) File "C:\Users\midga\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\indexes\base.py", line 3623, in get_loc raise KeyError(key) from err KeyError: 'contact_vcard'

filippz commented 2 years ago

My best guess would be that your result.json simply doesn't contain the key contact_vcard on at least one message because you didn't send/receive any vcards in this chat. You could send one vcard in the chat and try again or comment out the affecting code (https://github.com/filippz/telegram_import/blob/master/telegram_import.py#L36 and two lines below it).

Let me know if works.

ODENYGG commented 2 years ago

Heyo! thanks for the reply. So i commented out the lines, and it worked for a while, started exporting and then it just stops at 7%

Loading config.ini Loading result.json Converting format Staring import Upload files mentioned in messages Uploading (File not included. Change data exporting settings to download.): 7%|████████▏ | 23/307 [00:12<02:18, 2.05it/s][WinError 2] The system cannot find the file specified: 'C:\Users\midga\Desktop\Prova json\(File not included. Change data exporting settings to download.)' Uploading (File not included. Change data exporting settings to download.): 7%|████████▏

filippz commented 2 years ago

Instead of actual filename there seem to be the text: (File not included. Change data exporting settings to download.) I assume that you need to export the chat again and select to download the actual files and retry.

ODENYGG commented 2 years ago

OK. I'm so happy right now, i apologise. I think i finally made it work. So, for people coming here with the same question getting the upload stuck, my mistake was only exporting chat messages without Gifs, Videos, Audio, Files, Photos and all that stuff. So, what it wants you to do, is select ALL the things and only then it works flawlessly. It. F*cking, Works. Now i need to make it work on my GF's phone and i'm fantastic. Thank. You. So. Much.

I'd like to send you a tip and buy you a beer at least, send me info @ sir_winter@live.it