Extract Data From Multiple Files | Python CSV File Handling

preview_player
Показать описание
This tutorial shows how to read data from multiple csv files and create or write to new files based on requirement.
Рекомендации по теме
Комментарии
Автор

This saved me. thank you 1 billion times.

obileyeoladotun
Автор

How do you specify the exact location -- FOLDER ie - of the CSV FILES?

AlCatrraz
Автор

Hi really good tutorial however when I have def main(): defined my scripts stops working. No output att all but if I comment out lie 11, 12, 23 and 24 it prinst the whole object list. Is tehre any suggetsions for my problem? Python 3.10.

import csv

class traffic:
def __init__(self, trip_id, operating_date, journey_gid, stop_times_trip_id=None, stop_times_arrival_time=None):
self.trip_id = trip_id
self.date=operating_date
self.journey_gid = journey_gid

self.arrival_time = stop_times_arrival_time

def main():
all_objects = []


with open('todays_trips.csv', 'r') as f:
reader = csv.reader(f)
print(reader)
for each in reader:
print(each)
trip_id = each[0]
operating_date = each[1]
journey_gid = each[2]
data = traffic(trip_id=trip_id, operating_date=operating_date, journey_gid=journey_gid)
all_objects.append(data)
print(each)

marcuskarlsson