-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathget_likes_from_json_to_csv.py
More file actions
33 lines (28 loc) · 1.4 KB
/
Copy pathget_likes_from_json_to_csv.py
File metadata and controls
33 lines (28 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import argparse
import json
import pandas as pd
import settings
from src.core import create_df_statuses, get_likes_from_json
from src.tinybird import append_likes_csv
from src.utils import jprint
if __name__ == "__main__":
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument('-i', '--input', help='Input js file', default='data/like.js')
parser.add_argument('-o', '--output', help='Destination file', default='data/likes.csv')
parser.add_argument('-f', '--format', help='Format of specific columns of the csv: raw or gsheets', default='raw')
parser.add_argument('-pu', '--parse-urls', action='store_true', default=False, help='Parse the URL of the tweets that have one')
parser.add_argument('-j', '--save-json-col', action='store_true', default=False, help="Save a JSON column with all the tweet info")
args = parser.parse_args()
input_file = args.input
output_file = args.output
output_format = args.format
parse_urls = args.parse_urls
print(args)
likes = get_likes_from_json(input_file=input_file,
output_format=output_format,
parse_urls=parse_urls)
print(len(likes), 'likes parsed in total')
df = create_df_statuses(likes, save_json_col=args.save_json_col, output=output_file)
response = append_likes_csv(file=output_file)