#π How to adjust a .csv file
97 messages Β· Page 1 of 1 (latest)
@willow narwhal
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
what do you mean by adjust?
I cant see the thing, can you paste in the sentence you mean that I wrote so I can elaborate on it.
Oh okay sorry about that, yea I will explain
I currently have a email scraping code that scrapes emails off of websites I list in the url_list and then once it has found emails it prints them in to the email.csv file alongside with the website in url_list that is scraped the email from and also the url_list itself.
Why can't I paste in my code?
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
use that and send the link
!paste
Okay so, I just entered everything in to this url. I am sort of new to this python discord community so sorry about it but here's the whole thing and the parts with are code in the url paste thing and then the rest is just explanation text:
ok i read that, and to be honest i didnt really graps what youre trying to do
so you want a .csv file with rows like this
[email protected] , websiteurl.com , anotherurl?!.com
?
is that it?
or just
[email protected]
also, before anything, do those websites allow you to scrap them?
So basically this is how it currently prints the .csv file:
https://www.jacksonph.com/, [email protected]
email, link, url
http://www.jacksonph.com
https://www.deadriver.com
I want to add it to swap the urls like jasonph.com and deadriver.com that are after the email, link, url part with the corresponding emails that it scraped so like this:
https://www.jacksonph.com/, [email protected]
email, link, url
[email protected]
[email protected], [email protected]
Yes, they are my clients both of them. I have had a call with them asking if I could use their websites for a project like this.
okay
so what is the intended structure of the csv file?
link and url are the same thing btw
yea I know π wasn't able to do it without having 3 columns which was weird so just named them something random.
Basically to have the emails that have been scraped to be placed where the current website url is. so that it is very easy to copy.
Like in the example I gave you.
shouldnt a csv contain just rows of inputs?
with a specific notation
email, link, url
Maybe, I dont really know, I got error messages complaining about columns and field of certain rows being insufficient that it expected more or less.
yeah
well csv work like tables
you cant just write text like a txt file and then iterate through it with python and get no errors, instead treat it like an excel table
you columns are devided by commas
if want csv to store a list of rows with the following format (email, link) then you need to always abude by that format everytime you write in there
with that said, you cant really have emails scattered around the file and unfilled rows
so what youre trying to do isnt reslly suitable for csv
but maybe we can make it work
why dont you just store the emails like this
email, websiteitstakenfrom.com
so every row should contain something like
also, why wiuld you want to have the emails repeated at the end of the file, just for ease of use?
because csv files arent supoosed to be used to copy and paste from it by humans, instead you are supposed to have a program that fetches the data and displays it to the user
Oh okay, that is smart will try to do it like that! Thanks Spl1ce
cool let me know how it turns out or if you have any issues with it
Couldn't find a good way to otherwise get the copy of it because what I want is to have them in a google sheets or excel file where the website urls will be on rows, so basically every empty string or website url in the url_list will be its own row, then I wanted to easily just click on the top row of the excel and just paste it in so that the emails would be placed on the same rows as their corresponding website without having to manually paste in all the emails, if that makes sense.
what is the url_lidt supposed to be?
im not quite grasping why youd want to do that, but im probsbly missing the context
No well if you mean what it is doing printing inside the .csv was because I was thinking that since the scraper will print out the website that is scraped from which is the exact same as the one in url_list and also the email I thouhgt I could use the url_list, print it in the .csv file and basically use that as a navigator for the website, and email row so that it knew where to place it.
okok i see, and how do the empty rows happen?
By having empty strings in the url_list
url_list is a python list?
No just a variable or array.
so a python list
Oh yea π
ahah
Read it like library π
well i just dont understand why youd have empty elements in the list
or empty strings
Well it is mainly because some doesnt have websites but I still want to keep them in the excel so the empty strings is to compensate it so I can just paste it in so that the website companies gets companied by the email
oh okay i see
okokok so you want a csv file with the emails of your clients and their website
some of them dont have websites
Yea exactly and those I want to skip and not accidentally address a email to if that makes sense
so how are you supoosed to then paste them to their corresponding websites if they dont have one ?
what so you mean with address an email to?
Well then they will be skipped so you can view the url_list as all the empty strings "" are the businesses without a website and then the ones with url have a website and an email
Address an email to the ones that has a website.
ok
why dont yyou insert them in a row like this
[email protected], βNo websiteβ
i think that is the way to go
Yea me too now that you said it, thaks spl1ce for the help!!!
then youd still have a list of every single email with website attached to them and you know which ones dont have
ye
yw
let me know how it turns out and if you need more help
Yea will do thanks! πͺ
It worked! Thanks bro for the help πͺ
!solved
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.