Reputation: 1
New to python, but have about 3+ years of amateur experience in C.
I have a .csv file in Excel with about 30 URLs in a column in the following format:
b'https://www.facebook.com/ESPN/posts/1914426995270714'
How do I iterate through the column with these URLs in the Excel file and edit the strings to turn them into links like this:
'https://www.facebook.com/ESPN/posts/1914426995270714'
Also, what module could I use to open the links and write their contents (the text) to a new column? I know there are plenty of modules to grab the article contents but I don't know how to actually write that into the csv after.
Thanks so much!
Upvotes: 0
Views: 80
Reputation: 145
check the 'csv' module. use this code to read the data
import csv
with open('yourfileName.csv', mode='r') as infile:
reader = csv.reader(infile)
for rows in reader:
data = rows[2:-1] #to remove the b' and ' characters
then you will most probably need a simple web scraper to read the data from each link, check "thenewboston" web crawler playlist on youtube, you can start from there.
Upvotes: 2