How to pull data from a CSV file in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ธ.ค. 2021
  • Hello everyone, today's video is a short one but a good one. I have been using CSV files a lot in my current project for my data structures and algorithms 2 class. I had a lot of issues early on trying to get the data in to the lists and print it so I figured this would be a good video. Let me know what you think in the comments and please subscribe if you are not yet, I'm trying to get to the 1000 subs mark :).
    discord: / discord
    Peter-Pyke on GitHub

ความคิดเห็น • 35

  • @thefrub
    @thefrub 4 หลายเดือนก่อน

    Thank you for the explanation, I'm working on a project that has almost this exact problem rn and this helped me understand it better

    • @Chewy21414
      @Chewy21414  4 หลายเดือนก่อน

      Glad it helped thank you for watching ☺️

  • @esmaben1
    @esmaben1 4 หลายเดือนก่อน +1

    Thank you for this video! I have a question: How to would be, if i want that myList had a array of objects?

    • @Chewy21414
      @Chewy21414  4 หลายเดือนก่อน

      Hey I'm glad you liked the video. Unfortunately I haven't done anything with python in a while so I don't know the answer to your question right now. I haven't kept up with this type of coding since I finished college.
      However maybe this could help? stackoverflow.com/questions/7925539/store-and-retrieve-objects-from-python-lists

  • @lomar-om6hc
    @lomar-om6hc 2 หลายเดือนก่อน +1

    Thank you so much for your video! I’ve learned a lot! I have one question, how am I able to do the exact same function without csv.reader? My professor doesn’t want us using that, and I’m not sure how else to do it.

    • @Chewy21414
      @Chewy21414  2 หลายเดือนก่อน +2

      I wish I could be more helpful but it's been so long time since I did this video I really don't know. I haven't had to do anything with data and CSV files in a long time. I have been trying to learn C# and Unity/game development.

    • @lomar-om6hc
      @lomar-om6hc 2 หลายเดือนก่อน +1

      @@Chewy21414 that’s alright, I understand! Thank you for your help and responding back! I really appreciate it!

  • @user-xe4tm8no1n
    @user-xe4tm8no1n 4 หลายเดือนก่อน

    Thanks for the video. I have a question. I am trying to take 9 different raw data files, convert to csv, parse as needed, fix missing values, etc. Run exploratory analysis on the csv using python. Then I have to take those 9 files and combine into one file and run exploratory analysis. Do I need to use excel to convert to CSV first for each one or can I use python to perform that function for me. How do I import the files into my python project so I do not have to use pathways? I appreciate any help. Good video.

    • @Chewy21414
      @Chewy21414  4 หลายเดือนก่อน

      Hey thank you for watching. I don't recall a time where I had to convert files but I'm pretty sure python has a function that can handle converting the files to csv. Importing the files into your project is just a matter of saving the files in the correct location. If you save them inside a fold where your project is you should be able to access them without having to use an absolute file path. Not sure if that helps much but hope you are able to figure it out and complete your project.

  • @brunomachado8571
    @brunomachado8571 ปีที่แล้ว +2

    Hey Porkchop. I´m trying to retrieve number values from a csv file and store them as json, without the Quotation mark. Any link to one of your videos? Thanks I want to store them like [32.789, 8.456] (like coordinates)

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว

      I haven't done any videos with json files. Only time I have used json files is when pulling data into a Jupyter notebook. Perhaps in the coming weeks I can create a video to try to do something similar and post it.

  • @adey1434
    @adey1434 ปีที่แล้ว +3

    How can we extract data against specific date from column?

  • @vanishreevelmurugan7225
    @vanishreevelmurugan7225 ปีที่แล้ว

    what is the tool you are working now? i have downloaded python setup but my screen is not same as you working in the video now.
    Please tell me what to install to type the code like you do

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว

      I am using IntelliJ, I have a video on how to set python up with it. th-cam.com/video/OV6k33GH2Vk/w-d-xo.html

  • @adanordonez7241
    @adanordonez7241 ปีที่แล้ว

    In 5:50, how can I append to the list all the values that are located in just one column?

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว +1

      It's been awhile since I have done anything with text files in Python. But if I were to do it I think I would just set up a loop to modify the particular index from each row that I wanted. Again like I said I haven't done much with python in awhile so sorry if my answer is not very helpful. If you figure out how to do it though reply to this comment with the answer so the other people looking to do the same will have the answer.

  • @yaweli2968
    @yaweli2968 ปีที่แล้ว +2

    I wish you could show how to extract specific columns, but thanks for the video

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว

      I have a couple other videos on text files that might help check my playlists. I thought I went over that in one of them it's been awhile since I did it though so I'm not sure.

    • @yaweli2968
      @yaweli2968 ปีที่แล้ว

      Please drop a link. I have trying to look it up

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว

      @@yaweli2968 try one of these videos th-cam.com/video/vrL_c0lqLUE/w-d-xo.html
      th-cam.com/video/B1ggSnhMyEQ/w-d-xo.html

  • @sagarsrinivas457
    @sagarsrinivas457 ปีที่แล้ว

    how to extract text (if possible specific section text ) from multiple resume extension as doc,docx, pdf and save all into a new csv file in 3 row data entry system.

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว +1

      I am not sure at this point. I haven't done a lot with text files and python in a while I have been learning #C and game development in Unity.

  • @prisharai792
    @prisharai792 6 หลายเดือนก่อน

    what software is this?

    • @Chewy21414
      @Chewy21414  6 หลายเดือนก่อน

      The IDE called IntelliJ I have a video on my TH-cam about how to set up Python inside IntelliJ.

    • @prisharai792
      @prisharai792 6 หลายเดือนก่อน

      okay thanks@@Chewy21414

  • @reddeadcobra8295
    @reddeadcobra8295 ปีที่แล้ว

    Let’s say I have a csv file with 2 columns. I have years on one column and sales amount in the second. The issue I am having is that I don’t know how to make a list with the year because I need to calculate the means for them. How would I create a list with all the years

    • @robn2497
      @robn2497 ปีที่แล้ว

      once you have a list of lists, example = [[year , sales_amount] , [1999, 10,000 ], [2000, 15,000], [2001, 17,000] ] to access the year 1999 use index 1 which maps too [1999, 10,000 ], so A = example[1], A will now contain [1999, 10,000 ], u can now access the year --> 1999 OR sales--> 10,000 using indexing again, B =A[0] would be 1999 OR C =A[1] would be 10,000 remember python indexes start from zero so 1st element [0] 2nd [1] 3rd [2] ect ect. Its just a 2 step process, you could write a loop to do this systematically append() to make a list containing whatever you wanted to average (find the mean).

  • @TheCopperMystic
    @TheCopperMystic 3 หลายเดือนก่อน

    You are so handsome and your voice. Gosh!

  • @thippeswamykv2527
    @thippeswamykv2527 2 ปีที่แล้ว +1

    how to store the data in CSV FILES proper format using python

    • @Chewy21414
      @Chewy21414  2 ปีที่แล้ว +1

      Are you asking how to explort data from a python project into a csv file in a certain format? I have a few other videos on my channel with text files check those out and if you still have questions feel free to join my discord and chat.

    • @thippeswamykv2527
      @thippeswamykv2527 2 ปีที่แล้ว

      @@Chewy21414 That's grate thanks if you don't ,mind can you please share the vdo link

    • @Chewy21414
      @Chewy21414  2 ปีที่แล้ว

      @@thippeswamykv2527
      Here are the links to the other two videos and also the link to my discord
      th-cam.com/video/B1ggSnhMyEQ/w-d-xo.html
      th-cam.com/video/vrL_c0lqLUE/w-d-xo.html
      discord.gg/KehtBFGh

  • @discere5811
    @discere5811 ปีที่แล้ว +1

    I am getting an error;
    NameError: name 'filename' is not defined
    how do I fix this? I hope you answer my question, thank you in advance.

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว

      Do you have the import csv at the top?

    • @Chewy21414
      @Chewy21414  ปีที่แล้ว

      Also make sure you have filename as a parameter of the load_data function.