Python CSV Module - Reading Files and Skipping Rows

preview_player
Показать описание
In this video, we'll learn how to read CSV data from a file into Python applications, using the csv module.

Finally, we'll quickly demonstrate how easy it is to load CSV data into Pandas DataFrames.

▶️ Full Playlist:

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:22 Reading file with csv reader
03:15 Reading file with csv DictReader
04:58 Skipping row with next() built-in
07:49 Skipping multiple rows with next() built-in
08:16 Skipping rows with itertools islice function
09:45 Reading CSV file with Pandas

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:

#python #csv #pandas
Рекомендации по теме
Комментарии
Автор

and here's one that skips ALL commented lines! (i.e. line starts with '#')
import csv

def read_csv():
''' Creates a generator with uncmmented rows in csv '''
with open('test.csv', 'r') as csvfile:
reader = csv.DictReader(csvfile, delimiter=';')
headers = reader.fieldnames
for k in reader:
if not
yield k

# --- usage
items = read_csv()
for item in items:
print(item)

ulfgj
Автор

very useful video on an important topic in Python. The repos and gists are very helpful.

iwswordpress
Автор

Always got some to learn with you mate. Keep going !

seydinaoumarsamabaly
Автор

Great video, helped me solve a DF issue I was having.

trevorbanning
Автор

This really cool!! Your video is very easy to understand!! Hope you will do more video!!

lruslip
Автор

Just saved my uni assignment, thanks lol🤣

Illack
Автор

You are a lowkey guy teacher! hope you get big soon, your htmx series was helpful to me!

imbesrs
Автор

Another great video! Would love to see a tutorial on how to run automated/scheduled tasks from a Django project.

studioteque
Автор

Is csvreader the best module for analyzing a csv file? For example, reading from any csv-line, jumping around randomly?

For example, I'd like to display a csv-line in a gui (one line at a time), but would like for the user/gui thread to tell the csv thread to skip to line X, or to rewind to 10 lines?

bennguyen
Автор

How to skip particularly few rows in between from the csv file

susantasarkar
Автор

Lovely video. I want to ask a question, if you want to read only one like from your DictReader, analyse the line and remove it from the file

oyeleyeolalekan