We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Given a chat with the following format:
2015-08-22, 12:15 PM - X: bla bla 2015-08-22, 12:15 PM - Y: bla 2015-08-22, 12:16 PM - Y: blabla 2015-08-22, 12:17 PM - X: bla
Both with auto_header option
auto_header
>>> from whatstk import WhatsAppChat >>> chat = WhatsAppChat.from_txt('example.txt')
and manually setting hformat
hformat
>>> from whatstk import WhatsAppChat >>> chat = WhatsAppChat.from_txt('example.txt', hformat='%y-%m-%d, %P:%M - %name:')
a KeyError exception is raised:
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 2656 try: -> 2657 return self._engine.get_loc(key) 2658 except KeyError: pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'date' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) <ipython-input-4-5e2de28f6c26> in <module> ----> 1 chat = WhatsAppChat.from_txt(filename) ~/whatstk/whatstk/objects.py in from_txt(cls, filename, auto_header, hformat, encoding) 44 hformat.replace('[', '\[').replace(']', '\]') 45 # Prepare DataFrame ---> 46 df = cls._prepare_df(text, hformat) 47 48 return cls(df) ~/whatstk/whatstk/objects.py in _prepare_df(text, hformat) 79 80 # Parse chat to DataFrame ---> 81 df = parse_chat(text, r) 82 83 # get rid of wp warning messages ~/whatstk/whatstk/utils/parser.py in parse_chat(text, regex) 51 line_dict = _parse_line(text, headers, i) 52 result.append(line_dict) ---> 53 df_chat = pd.DataFrame.from_records(result, index='date') 54 return df_chat[['username', 'message']] 55 /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py in from_records(cls, data, index, exclude, columns, coerce_float, nrows) 1527 if (isinstance(index, compat.string_types) or 1528 not hasattr(index, "__iter__")): -> 1529 i = columns.get_loc(index) 1530 exclude.add(index) 1531 if len(arrays) > 0: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 2657 return self._engine.get_loc(key) 2658 except KeyError: -> 2659 return self._engine.get_loc(self._maybe_cast_indexer(key)) 2660 indexer = self.get_indexer([key], method=method, tolerance=tolerance) 2661 if indexer.ndim > 1 or indexer.size > 1: pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'date'
The text was updated successfully, but these errors were encountered:
created new branch to fix 12h header format detection. Added text exa…
d2823bc
…mple file. Issue #40
Manually setting format works, should be as:
>>> from whatstk import WhatsAppChat >>> chat = WhatsAppChat.from_txt('example.txt', hformat='%y-%m-%d, %H:%M %P - %name:')
Now working on making auto_header option available for 12h clock.
Sorry, something went wrong.
lucasrodes
Successfully merging a pull request may close this issue.
Given a chat with the following format:
Both with
auto_header
optionand manually setting
hformat
a KeyError exception is raised:
The text was updated successfully, but these errors were encountered: