User Participation #14
-
Thank you very much for this source! Is it also possible to also extract specific users' posts in different subreddits into a csv file? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @yazgiakata57, Thank you for your question. Yes, it is possible to extract specific users' posts that they've uploaded across different subreddits and download them into a CSV file, provided that you have their usernames. If you have usernamesIf you already have a collection of usernames, you can create a list of from redditharbor.dock.pipeline import collect
users = [...] # your collection of usernames
collect.submission_from_user(users=users, sort_types=["controversial"], limit=10) To collect all possible submissions from these users, you can use the following code: collect.submission_from_user(users=users, sort_types=["new", "hot", "top", "rising", "controversial"], limit=None) After collecting the submissions, you can download the posts made by the specific users to a CSV file: from redditharbor.utils import download
download_instance = download.submission(supabase_client, DB_CONFIG["submission"])
download_instance.to_csv(columns="all", file_name="<your-file-name>", file_path="<your-folder-name>") If you do not have usernamesIt's unlikely that most researchers would have a collection of usernames before using RedditHarbor. In that case, I suggest collecting usernames from the subreddits of interest first, and then fetching user data from the database. Here's an example: from redditharbor.dock.pipeline import collect
from redditharbor.utils import fetch, download
# Collect submissions and user data from subreddits
collect = collect(reddit_client, supabase_client, DB_CONFIG)
subreddits = [...] # your collection of subreddits
sort_types = ["new", "hot", "top", "rising", "controversial"]
collect.subreddit_submission(subreddits, sort_types, limit=100)
# Fetch usernames from the user database
fetch_user = fetch.user(supabase_client, DB_CONFIG["user"])
users = fetch_user.name(limit=None) # Set limit=None to fetch all usernames
# Collect submissions made by the fetched users
collect.submission_from_user(users=users, sort_types=sort_types, limit=None)
# Download submissions to CSV
download_instance = download.submission(supabase_client, DB_CONFIG["submission"])
download_instance.to_csv(columns="all", file_name="<your-file-name>", file_path="<your-folder-name>") This approach allows you to collect usernames from specific subreddits, fetch their submissions, and then download the data to a CSV file. Let me know if you have any further questions or face issues! We will aim to answer within 24 hours. |
Beta Was this translation helpful? Give feedback.
Hey @yazgiakata57,
Thank you for your question. Yes, it is possible to extract specific users' posts that they've uploaded across different subreddits and download them into a CSV file, provided that you have their usernames.
If you have usernames
If you already have a collection of usernames, you can create a list of
users
and pass it as an input tocollect.submission_from_user
. The code below will collect the top 10 most controversial submissions made by each user:To collect all possible submissions from these us…