#πŸ”’ How to adjust a .csv file

97 messages Β· Page 1 of 1 (latest)

umbral mortarBOT
#

@willow narwhal

Python help channel opened

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.

sullen needle
#

what do you mean by adjust?

willow narwhal
#

I cant see the thing, can you paste in the sentence you mean that I wrote so I can elaborate on it.

sullen needle
#

?

#

You wrote: How to adjust a .csv file?

willow narwhal
#

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?

sullen needle
#

!paste

umbral mortarBOT
#
Pasting large amounts of code

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.

sullen needle
#

use that and send the link

willow narwhal
#

!paste

sullen needle
#

read that embed

#

read the whole thing

willow narwhal
sullen needle
#

ok

#

so whats the problem?

willow narwhal
#

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:

https://paste.pythondiscord.com/V6JQ

sullen needle
#

ok i read that, and to be honest i didnt really graps what youre trying to do

#

?

#

is that it?

#

also, before anything, do those websites allow you to scrap them?

willow narwhal
willow narwhal
sullen needle
#

okay

sullen needle
#

link and url are the same thing btw

willow narwhal
willow narwhal
#

Like in the example I gave you.

sullen needle
#

shouldnt a csv contain just rows of inputs?

#

with a specific notation

#

email, link, url

willow narwhal
#

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.

sullen needle
#

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

#

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

willow narwhal
sullen needle
#

cool let me know how it turns out or if you have any issues with it

willow narwhal
# sullen needle because csv files arent supoosed to be used to copy and paste from it by humans,...

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.

sullen needle
#

im not quite grasping why youd want to do that, but im probsbly missing the context

willow narwhal
#

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.

sullen needle
willow narwhal
#

By having empty strings in the url_list

sullen needle
#

url_list is a python list?

willow narwhal
#

No just a variable or array.

sullen needle
#

so a python list

willow narwhal
#

Oh yea πŸ˜…

sullen needle
#

ahah

willow narwhal
#

Read it like library πŸ˜‚

sullen needle
#

well i just dont understand why youd have empty elements in the list

#

or empty strings

willow narwhal
#

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

sullen needle
#

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

willow narwhal
#

Yea exactly and those I want to skip and not accidentally address a email to if that makes sense

sullen needle
sullen needle
willow narwhal
#

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

willow narwhal
sullen needle
#

ok

willow narwhal
#

That's true I could do that

#

Let me try fixing it, might take some time though

sullen needle
#

i think that is the way to go

willow narwhal
#

Yea me too now that you said it, thaks spl1ce for the help!!!

sullen needle
#

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

willow narwhal
#

Yea will do thanks! πŸ’ͺ

willow narwhal
#

It worked! Thanks bro for the help πŸ’ͺ

sullen needle
#

nice!

#

wel i guess we can close this now

#

good luck with your business

willow narwhal
#

Yea we can, it was nice to chat spl1ce thanks

#

You too, have a good day and life!

sullen needle
#

thanks

#

!close

#

!solved

#

i guess it needs to be you

willow narwhal
#

!solved

umbral mortarBOT
#
Python help channel closed

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.