lucasrodes / whatstk

WhatsApp chats as dataframes. Python toolkit to analyse and parse WhatsApp chats.
https://whatstk.lcsrg.me/
GNU General Public License v3.0
125 stars 22 forks source link

IndexError: list index out of range #17

Closed reinaldogani closed 6 years ago

reinaldogani commented 6 years ago

I can't seem to parse my whatsapp txt file Format is [MM/DD/YYYY hh:mm:ss PM] - username: message

Do you have solution for this? Your help is much appreciated screen shot 2018-01-29 at 18 53 18

lucasrodes commented 6 years ago

Can you please provide me with an example of the chat format? In particular, can you identify your header format in the list provided in #7 ?

From your comment, I understand that the format of your chat is like the following example (inspired by samplechat). Can you please verify this? I am getting a different error. Which language are you using?

04/15/2016, 15:04:10: You created group “Sample Group”
08/06/2016, 13:18:10: Messages you send to this group are now secured with end-to-end encryption. Tap for more info.
08/06/2016, 13:23:10: Ash Ketchum: Hey guys!
08/06/2016, 13:25:10: Brock: Hey Ash, good to have a common group!
08/06/2016, 13:30:10: Misty: Hey guys! Long time haven't heard anything from you
08/06/2016, 13:45:10: Ash Ketchum: Indeed. I think having a whatsapp group nowadays is a good idea
08/06/2016, 14:30:10: Misty: Definetly
08/06/2016, 17:25:10: Brock: I totally agree
08/07/2016, 11:45:10: Prof. Oak: Kids, shall I design a smart poke-ball?
08/07/2016, 18:45:10: Ash Ketchum: I don't mind Prof. I quitted capturing pokemon.
08/07/2016, 19:30:10: Misty: Was a great time, but had enough also.
08/07/2016, 23:25:10: Brock: Guys, I am still in the first gym. No one is playing pokemon, they went crazy with pokemon Go.
08/10/2016, 09:45:10: Jessie & James: Hey, thanks for adding us. Wanna meet soon? Just for the old times.
08/10/2016, 11:25:10: Raichu: I am in!
08/10/2016, 13:23:10: Ash Ketchum: FFS, no way, Pikachu did you evolve?
08/10/2016, 15:23:10: Raichu: Yes... Weird to have a different body!
08/11/2016, 19:30:10: Misty: Gotta see that.
09/11/2016, 20:25:10: Meowth: Hey people, I was on holidays in Sinnoh. Crazy region.
10/31/2016, 11:45:10: Prof. Oak: Smart-pokeball is created.
10/31/2016, 12:23:10: Wobbuffet: Wo-bbu-ffet
reinaldogani commented 6 years ago

Mine has [] outside the timestamp. I attach the screenshot below. I am using Bahasa Indonesia as medium of group chat. Do you know if there is any way that whatsapp can change exported timestamp format?

screen shot 2018-01-30 at 00 11 12

lucasrodes commented 6 years ago

Thanks for your message. I was not aware of this kind of format. I have added your format to the list in #7 and will update the code of whatstk to support this format. I will let you know! ;)

lucasrodes commented 6 years ago

@reinaldogani I have updated the code, please clone again. To import your chat please use:

import whatstk.parser as wp
import whatstk.vis as wv
chat = wp.WhatsAppChat("Users/reinaldogani/Desktop/family.txt", date_format='mdy')

Note that I have added a new argument (date_format), which defines the date format of your header. Namely, your chat uses MM/DD/YYYY, hence 'mdy' (m: month, d: day, y:year). Please let me know how it goes!

I am planning to upload clearer documentation on this project in the near future.

reinaldogani commented 6 years ago

@lucasrodes Thank you for the fix! I try again, but I get an error as can be seen in the picture below. screen shot 2018-01-30 at 22 27 43

lucasrodes commented 6 years ago

@reinaldogani, try to append the folder containing the library whatstk instead of the library itself.

import sys
sys.path.append("/Users/reinaldogani/Desktop")

Then simply import the parser as

import whatstk.parser as wp
chat = wp.WhatsAppChat("Users/reinaldogani/Desktop/EEE_seniors.txt", date_format="mdy")
reinaldogani commented 6 years ago

@lucasrodes - it is working perfectly. Thank you!

lucasrodes commented 6 years ago

Nice, glad to hear that!