CSV Column To Python List

Поделиться
HTML-код
  • Опубликовано: 15 дек 2024

Комментарии • 44

  • @mansoorghumro8404
    @mansoorghumro8404 3 года назад +10

    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!

    • @DataEngUncomplicated
      @DataEngUncomplicated  3 года назад +1

      I'm glad the video was helpful! Thank you for leaving a comment!

    • @nishantkumar-lw6ce
      @nishantkumar-lw6ce 3 года назад

      You could also use pandas library to convert to list.

  • @tarunsoni2764
    @tarunsoni2764 3 года назад +3

    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

  • @richardallen1555
    @richardallen1555 Год назад +1

    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

  • @teach4944
    @teach4944 2 года назад +1

    Danke!

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад +1

      Wow thanks for the super thanks Joshua, it is very much appreciated!

  • @the_dev_life
    @the_dev_life 4 года назад +3

    Very useful video! Well paced and very clear. 👏

  • @teach4944
    @teach4944 2 года назад

    you just safed me hours of typing. thanks a lot

  • @mahsaamini8555
    @mahsaamini8555 2 года назад +1

    Very useful video, thank you!

  • @vitorribeirosa
    @vitorribeirosa Год назад

    Thanks for sharing this very useful content.
    Cheers!!!!

  • @romanvavryk8880
    @romanvavryk8880 3 года назад +1

    Thanks mate, you saved my life

  • @chritophergaafele8922
    @chritophergaafele8922 Год назад +1

    Thank you very much

  • @KhalilYasser
    @KhalilYasser 4 года назад +3

    Awesome. Thanks a lot...

  • @mercedehsasanpour5575
    @mercedehsasanpour5575 2 года назад

    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!

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад

      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.

    • @mercedehsasanpour5575
      @mercedehsasanpour5575 2 года назад

      @@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.

  • @revenge9431
    @revenge9431 3 года назад +1

    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

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад

      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.

  • @anurathilakbandara3705
    @anurathilakbandara3705 2 года назад

    how to find transpose of single column data?

  • @scarletv.3825
    @scarletv.3825 2 года назад

    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.

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад

      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).

  • @iamvalenci4
    @iamvalenci4 2 года назад

    thank you!!

  • @maxli913
    @maxli913 2 года назад

    It’s saying my ‘title’ is not defined

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад

      Hi Max, without much context I'm not sure what this relates to

    • @maxli913
      @maxli913 2 года назад

      @@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

    • @DataEngUncomplicated
      @DataEngUncomplicated  2 года назад +1

      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

    • @maxli913
      @maxli913 2 года назад

      @@DataEngUncomplicated oki thank you

    • @maxli913
      @maxli913 2 года назад +1

      @@DataEngUncomplicated you are such a nice RUclipsr btw there aren’t much people like you out there so keep up the good work 😊

  • @PCAN411
    @PCAN411 4 года назад

    Do you know that the audience cannot see what you are talking about because of font size too small?

    • @DataEngUncomplicated
      @DataEngUncomplicated  4 года назад

      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.