-1

This code below works fine, but the data pasted via csv lib onto a CSV file leaves a row blank for every entry and I'm struggling to see why.

import praw
import configReddit
import csv

reddit = praw.Reddit(
    client_id=configReddit.client_id,
    client_secret=configReddit.client_secret,
    password=configReddit.password,
    user_agent=configReddit.user_agent,
    username=configReddit.username,
)

with open('blockchainstable.csv', 'w', encoding="utf-8") as csvfile:
    comment_writer = csv.writer(csvfile)
    for comment in reddit.subreddit("CryptoCurrency").stream.comments():
        print(comment.body)
        comment_writer.writerow([comment.body])

enter image description here

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
A. Prats
  • 59
  • 10

1 Answers1

0

Add , newline='' as in the example in the docs. E.g.,

with open('blockchainstable.csv', 'w', encoding="utf-8", newline='') as csvfile:
    ...