MasterScrat / Chatistics

💬 Python scripts to parse Messenger, Hangouts, WhatsApp and Telegram chat logs into DataFrames.
https://masterscrat.github.io/Chatistics/
MIT License
930 stars 100 forks source link

Make beginner-friendly guide on how to use #27

Open MasterScrat opened 5 years ago

MasterScrat commented 5 years ago

Multiple people with little knowledge of Python have expressed interest in running the scripts.

There should be either a very simple guide or video, or a guided script that would let anyone render the final graphics.

MasterScrat commented 4 years ago

Maybe a Colab notebook?

teamfridge commented 4 years ago

+1 any progress on this? Several hours deep and still not managed to get running, be great to find an easier (or any!) way to use this...thanks!

MasterScrat commented 4 years ago

Sorry to hear!

What problems are you hitting? Feel free to open issues for any kind of problem!

sheikheddy commented 4 years ago

I have a lot of experience with python, will jump into the repo and hopefully try to write a tutorial tomorrow.

teamfridge commented 4 years ago

Sorry to hear!

What problems are you hitting? Feel free to open issues for any kind of problem!

Thanks! Not related to this project more general python modules and libraries issues, the kind that often generate the unhelpful response r/learnpython elsewhere...but if I identify something specific to this I will let you know. Thanks again!

sheikheddy commented 4 years ago

Hi, just made a tutorial part 0 to help with installing and setting up chatistics. It's based off of a handout I made for a course I TA'd for, so let me know if you'd like to change anything! tutorialpart0.pdf

Part 1 will be a colab notebook, any suggestions for what to include in it?

Edit: Will make a .ipynb notebook instead

teamfridge commented 4 years ago

Got it working, thanks! Hit an obstacle with --own-name command not found, but skipped it by exporting two chats into the folder.

mar-muel commented 4 years ago

I would prefer using Binder since maybe not all users are comfortable sharing their chat history with Google? Although I don't have strong opinions on this.

sheikheddy commented 4 years ago

Isn't Google Cloud one of the supporters of binder? Anyway, good point, I'll make it a notebook they can run locally.

HaydenSchilling commented 4 years ago

Any Progress on the tutorial for beginners? I am hitting issues which I think are very basic as I"m new to python.

When I try and run the script for messenger I get the following error.


%run Chatistics/parse.py messenger

KeyError                                  Traceback (most recent call last)
~\Chatistics\parse.py in <module>
      2 import sys
      3 
----> 4 from parsers.config import config
      5 from utils import ArgParseDefault
      6 

~\Chatistics\parsers\__init__.py in <module>
      1 import logging.config
      2 
----> 3 logging.config.fileConfig('logging.conf')

~\.conda\envs\Chatistics\lib\logging\config.py in fileConfig(fname, defaults, disable_existing_loggers)
     69             cp.read(fname)
     70 
---> 71     formatters = _create_formatters(cp)
     72 
     73     # critical section

~\.conda\envs\Chatistics\lib\logging\config.py in _create_formatters(cp)
    102 def _create_formatters(cp):
    103     """Create and return formatters"""
--> 104     flist = cp["formatters"]["keys"]
    105     if not len(flist):
    106         return {}

~\.conda\envs\Chatistics\lib\configparser.py in __getitem__(self, key)
    956     def __getitem__(self, key):
    957         if key != self.default_section and not self.has_section(key):
--> 958             raise KeyError(key)
    959         return self._proxies[key]
    960 

KeyError: 'formatters'
sheikheddy commented 4 years ago

Oh, that issue might be because python can't find your 'logging.conf' config file. This is defined inside the Chatistics directory, so since your current working directory is being searched the logging.conf isn't found. Try navigating to inside the Chatistics folder first and running the command again?

I haven't forgotten about making the tutorial, it's just been hard to motivate myself. I'll try to see if I can block off time this weekend to work on it.

HaydenSchilling commented 4 years ago

Thanks, That worked! but now I have another problem. I am getting an error with the names. :(

%run parse.py messenger
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
~\Chatistics\parse.py in <module>
     82 
     83 if __name__ == '__main__':
---> 84     ArgParse()

~\Chatistics\parse.py in __init__(self)
     40             parser.print_help()
     41             sys.exit(1)
---> 42         getattr(self, args.command)()
     43 
     44     def telegram(self):

~\Chatistics\parse.py in messenger(self)
     67                             help='Path to Facebook messenger chat log folder')
     68         args = parser.parse_args(sys.argv[2:])
---> 69         main(args.own_name, args.file_path, args.max)
     70 
     71     def whatsapp(self):

~\Chatistics\parsers\messenger.py in main(own_name, file_path, max_exported_messages)
     17     if len(glob.glob(os.path.join(file_path, '**', '*.json'))) == 0:
     18         log.error(f'No input files found under {file_path}')
---> 19         exit(0)
     20     if own_name is None:
     21         own_name = infer_own_name(file_path)

NameError: name 'exit' is not defined
sheikheddy commented 4 years ago

This error is due to a missing import, I've made a pull request to fix it.

Just to make sure, have you put the contents of the messages folder (from your FB JSON download) into Chatistics/raw_data/messenger ?

HaydenSchilling commented 4 years ago

Yes, that is correct, I have the json files in Chatistics/raw_data/messenger but I think you are on the right track, they are not being recognised as input files.

image

sheikheddy commented 4 years ago

This is definitely strange.

This is the code snippet that's responsible for it:

https://github.com/MasterScrat/Chatistics/blob/079fb531a685bdd7ead81dab97a855da5c749c39/parsers/messenger.py#L17-L19

Let's contrast this with the empty input file checker in the whatsapp parser:

https://github.com/MasterScrat/Chatistics/blob/079fb531a685bdd7ead81dab97a855da5c749c39/parsers/whatsapp.py#L70-L73

Notice that in os.path.join, the messenger one has an extra '**'. I bet if you removed this you would fix this particular error. It seems what's going on is that the code expects you to put the messages folder inside instead of the contents of the messages folder. This goes against what README.md says.

Thanks for pointing this out!

HaydenSchilling commented 4 years ago

Amazing, works fine now! I really appreciate all your help!

kenyeresrudolf commented 3 years ago

Hey Guys,

IDK where is the error. After i downloaded the messenger data, copied into the raw_directory, created a venv in conda, set up a directory I tried to run parse.py messenger command (in anaconda terminal) , i still receive the following error. Could you please help me what could be the issue? Thank you a lot.

(chatistics) C:\Users\RUID2\Documents\PYProjects\Chatistics-master>python parse.py messenger Traceback (most recent call last): File "parse.py", line 84, in <module> ArgParse() File "parse.py", line 38, in __init__ if not hasattr(self, args.command): AttributeError: 'Namespace' object has no attribute 'command'