Is it possible to export topic post data to csv?

Is it possible to export topic post data to a csv file?

I’d like to take a topic post and all of it’s replies and turn it into a handy wiki (for example).

I could copy and paste the replies and find a good way to group them. However, if it’s easier to do an export of a topic and all replies I’d welcome the time saver.

If not an option via csv, could this be done via the data explorer?

I’d like to see the reply content along with the associated user who replied.

This might help, if not exactly what you ask, raw format:

https://meta.discourse.org/raw//295350

4 Likes

Yes, you can export the query result to a CSV file. You have a button for that action:

I’m not entirely certain if this is precisely what you had in mind, but I can provide you with a starting point. You provide a topic ID and the post number you want to get all replies from:

-- [params]
-- integer :topic_id
-- integer :post_number

SELECT u.id,
       u.username,
       p.raw,
       p.cooked
FROM topics t
JOIN posts p ON t.id = p.topic_id
JOIN users u ON p.user_id = u.id
WHERE t.id = :topic_id
  AND p.reply_to_post_number = :post_number
  AND p.hidden_at IS NULL
  AND p.deleted_at IS NULL

This looks like this:

4 Likes

Thanks for your advice, @merefield and @Arkshine.

I shall explore and give some things a go.

2 Likes