Jun-22-2020, 06:54 PM
As I am still working from home as part of the COVID-19 quarantine, I am trying to teach myself something new in this challenging time so please don't attack me if I seem really stupid, I am just trying to learn. There seems to be a lot of buzz about Python so I purchased a book titled, "Begin to Code with Python" by Rob Miles and have loaded v 3.7 on my desktop. As I starting thinking of things I want to learn with Python I downloaded information from Facebook to a file on my desktop. The file is in .html format and I would like to read each line in the file and change the order of the information and then save it as a .CSV file so I can do a statistical analysis of the data.
The input data has three components (see line below):
Ed liked Denise Robert’s comment. Jun 8, 2020, 5:58 PM
The first part shows an action I took in Facebook to "like" someone else's comment.
The second part did not show up as I cut and pasted but is a picture .
The third part is the date and time the action (ie Like) was taken.
As I started reading the book there are many things I have not really grasps yet and hope in time, with practice I will learn and understand.
I wrote the attached code which runs without any error messages but I am not accomplishing what I hope.
Any help or insights would be appreciated.
The input data has three components (see line below):
Ed liked Denise Robert’s comment. Jun 8, 2020, 5:58 PM
The first part shows an action I took in Facebook to "like" someone else's comment.
The second part did not show up as I cut and pasted but is a picture .
The third part is the date and time the action (ie Like) was taken.
As I started reading the book there are many things I have not really grasps yet and hope in time, with practice I will learn and understand.
I wrote the attached code which runs without any error messages but I am not accomplishing what I hope.
import html import csv import io with open('D:/Facebook/likes_and_reactions/posts_and_comments.html', 'r',encoding='utf-8' ) as html_file, open('Test_Python.csv', 'w') as out_file: reader = html_file.readlines() writer = csv.writer(out_file) print(writer) html_file.close() out_file.close()I would like to read each part as outlined about and then save: Part one, "a comma", Part three, "a comma" and then the picture reaction.
Any help or insights would be appreciated.