EDIT: in my attempt to narrow down my question I may have oversimplified in a way that makes it harder to answer. Let me try again. Assume that the dictionary is:
holder = {'key1':['headline1', 'body1'], 'key2':['headline2', 'body2']}
I'm looking to output that dictionary to a csv file that will represent that information in three columns: the key column, the headline column, and the body column. Trying to do that with the answer noted below failed for the reasons noted below.
Hopefully that's a bit more clear.
I'm scraping some chinese news sites and trying to output the results into a csv file. After scraping, the dictionary is structured:
uniqueID : [headlines, body]
for each story. I'm trying to output to a CSV that ultimately reads:
uniqueID1 / headlines1 / body1
uniqueID2 / headlines2 / body2
uniqueID3 / headlines3 / body3
with each of those in a different column (so basically three columns with as many rows as I have stories).
I tried using the solution from this question but, in addition to flipping the X and Y axis (which I know how to fix), it also broke out each character in each headline/story into a different entry and broke the character encoding. Since I don't know how to fix either of those problems I'm a bit stuck.
If it is helpful or relevant, I'm encoding the characters this way:
head_fixed = str(headline)
soup = BeautifulSoup(head_fixed, 'lxml')
good_output = soup.text.decode("unicode-escape").encode("utf-8")
Naturally, I'm also open to the suggestion that the way that I'm structuring the data is wrong.
Thank you for any ideas.