taspinar / twitterscraper

Scrape Twitter for Tweets
MIT License
2.4k stars 581 forks source link

Can't load tweets.json into Pandas df #187

Closed ElHong closed 5 years ago

ElHong commented 5 years ago

Hi, I managed to download my first tweets.json file but failed to import the file into a Pandas df. I followed the instructions (refer to point 3.1.2) within README.rst but it didn't work for me. Instead I get the following error message:

Traceback (most recent call last): File "/Users/PycharmProjects/tf_test/untitled/json_opener.py", line 5, in <module> tweets = json.load(f, encoding='utf-8') File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 296, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Can someone point me into the direction of solving this issue?

PS: I am using MacOS X 10.14.4, Python 3.7

taspinar commented 5 years ago

Can you try it as follows:

import pandas as pd
df = pd.read_json('tweets.json', encoding='utf-8')