Thank you.... I have been searching on how to convert a column in a csv to a list / dynamically calculate the number of unique elements in a HUGE csv file... or rather, since I'm so new to programming, didn't even know what to ask. You are a great help my friend. Be blessed!
BRUHHHH, literally , you solved my problem. actually i was given a csv file of almost 3000 rows and 5 column, and i was asked to calculate covariances , correlations, it helped me completely
i spent two days looking for a way to do my assignment and this 5 minute video was all i needed, i really need to get better at searching for what i dont know haha
Thank you. One question; how about the situation that I want to add a new column using the data I have in my csv file? for example I have 2 columns in my csv file called open and close. I want to add a new column that shows (close - open)/open I know it should be a code like follow with open('IBM.csv', 'r')as input: with open ('IBM.csv', 'w') as output: writer = csv.writer(output, lineterminator=' ') reader=csv.reader(input) And then I need to use append. but I have no idea now to put all this together and write my final code!
You're welcome. Have you used the python library pandas before? If your comfortable working with dataframes, if would be very easy to read the CSV file and then add a new column to it, then write it back to CSV.
@@DataEngUncomplicated Thanks, yes it can be done using pandas but I am trying to do it manually. so far I wrote this code: with (open('IBM.csv', newline='', encoding='utf-8') as infile, open('IBM.csv', 'w', newline='', encoding='utf-8') as outfile): reader = csv.DictReader(infile) writer = csv.DictWriter(outfile, fieldnames=['Open', 'Close']) writer.writeheader() for row in reader: #implement this formula (close - open)/open change = ['Close' - 'Open'] / ['Open'] change.append(IBM.csv) print(change.append(IBM.csv)) The first section should be right, but after #implement this formula is not.
hello, in your example. What if you wanted to continue with the next 10 rows, how would you write that? If you stop at row 10, rest for 1min then continue to the next ten until complete. thanks
I have a question after we pick the column. Is there a way to pick only certain rows within that column? I tried changing the "count." To start from a different number instead of 0 but that didn't work.
Do you know the criteria you want to pick your specific rows on? You would need to handle that once your data is in python. I don't think it can be done on read. ( I could be wrong).
@@DataEngUncomplicated hey I’m reading a csv file with movie names, rating, description, genre and etc.. I trying to print out the movie name and descriptions together like this when the user input is (‘P’) ( title : description title: description……) and I am thinking this will help with later when I need to add a Filter
Sounds like you want to use a python dictionary instead of a python list. Check out my other video that walks through how to get a python dictionary from a csv in python
Thank you.... I have been searching on how to convert a column in a csv to a list / dynamically calculate the number of unique elements in a HUGE csv file... or rather, since I'm so new to programming, didn't even know what to ask. You are a great help my friend. Be blessed!
I'm glad the video was helpful! Thank you for leaving a comment!
You could also use pandas library to convert to list.
BRUHHHH, literally , you solved my problem.
actually i was given a csv file of almost 3000 rows and 5 column, and i was asked to calculate covariances , correlations, it helped me completely
Hey Tarun, glad you found it helpful. Thanks for watching!
i spent two days looking for a way to do my assignment and this 5 minute video was all i needed, i really need to get better at searching for what i dont know haha
I'm glad it was helpful!
Danke!
Wow thanks for the super thanks Joshua, it is very much appreciated!
Very useful video! Well paced and very clear. 👏
Thanks a lot!
you just safed me hours of typing. thanks a lot
You're welcome Joshua!
Very useful video, thank you!
Thanks Mahsa, I'm glad you found it helpful!
Thanks for sharing this very useful content.
Cheers!!!!
Thanks Vitor!
Thanks mate, you saved my life
You're welcome Roman, I'm glad it was helpful.
Thank you very much
You're welcome!
Awesome. Thanks a lot...
You're welcome!
Thank you.
One question; how about the situation that I want to add a new column using the data I have in my csv file? for example I have 2 columns in my csv file called open and close. I want to add a new column that shows (close - open)/open
I know it should be a code like follow
with open('IBM.csv', 'r')as input:
with open ('IBM.csv', 'w') as output:
writer = csv.writer(output, lineterminator='
')
reader=csv.reader(input)
And then I need to use append. but I have no idea now to put all this together and write my final code!
You're welcome. Have you used the python library pandas before? If your comfortable working with dataframes, if would be very easy to read the CSV file and then add a new column to it, then write it back to CSV.
@@DataEngUncomplicated Thanks, yes it can be done using pandas but I am trying to do it manually. so far I wrote this code:
with (open('IBM.csv', newline='', encoding='utf-8') as infile,
open('IBM.csv', 'w', newline='', encoding='utf-8') as outfile):
reader = csv.DictReader(infile)
writer = csv.DictWriter(outfile, fieldnames=['Open', 'Close'])
writer.writeheader()
for row in reader:
#implement this formula (close - open)/open
change = ['Close' - 'Open'] / ['Open']
change.append(IBM.csv)
print(change.append(IBM.csv))
The first section should be right, but after #implement this formula is not.
hello, in your example. What if you wanted to continue with the next 10 rows, how would you write that? If you stop at row 10, rest for 1min then continue to the next ten until complete. thanks
I think on the read method, there should be a way to limit how many records are read in but I haven't tried this myself.
how to find transpose of single column data?
Hi anura, I discuss this in the second part of the video.
@@DataEngUncomplicated Thank you very much!
I have a question after we pick the column. Is there a way to pick only certain rows within that column?
I tried changing the "count." To start from a different number instead of 0 but that didn't work.
Do you know the criteria you want to pick your specific rows on? You would need to handle that once your data is in python. I don't think it can be done on read. ( I could be wrong).
thank you!!
You're welcome!
It’s saying my ‘title’ is not defined
Hi Max, without much context I'm not sure what this relates to
@@DataEngUncomplicated hey I’m reading a csv file with movie names, rating, description, genre and etc.. I trying to print out the movie name and descriptions together like this when the user input is (‘P’) ( title : description
title: description……) and I am thinking this will help with later when I need to add a Filter
Sounds like you want to use a python dictionary instead of a python list. Check out my other video that walks through how to get a python dictionary from a csv in python
@@DataEngUncomplicated oki thank you
@@DataEngUncomplicated you are such a nice RUclipsr btw there aren’t much people like you out there so keep up the good work 😊
Do you know that the audience cannot see what you are talking about because of font size too small?
Thanks for the heads up, I will make sure my next video uses a larger font. Setting the quality to 1080p will make sure the font is crisp.