So I have like 20,000 rows in a single column in Excel that contains all text. I'm trying to combine all the rows into a single cell that I call 'message' so then I can do some stuff in TextBlob, like count the number of sentences, but I'm not having any success combining all the text rows into one.
input (cant seem to copy and paste but formatted as a single column)
MsgBody
sure can
race game
like one of the biggest games
desired output:
sure can, race game, like one of the biggest games
actual output:
sure can
import csv
from textblob import TextBlob
import pandas as pd
input_csv = pd.read_csv(r'output.csv')
messages = input_csv['MsgBody']
allMessages = []
for message in messages:
allMessages.append(message)
With the full spec now, it seems you just want:
', '.join(messages)
This will take the array and transform it into a single comma-separated string.
PS: The copy-paste credit posting thing is an April Fool that seems rather counterproductive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With