Python Forum
importing CSV file into a OOP Class table using Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: importing CSV file into a OOP Class table using Python (/thread-25902.html)



importing CSV file into a OOP Class table using Python - faruk61 - Apr-15-2020

importing CSV file into a OOP Class table using Python . Help me ??


RE: importing CSV file into a OOP Class table using Python - faruk61 - Apr-15-2020

(Apr-15-2020, 09:11 AM)faruk61 Wrote: importing CSV file into a OOP Class table using Python . Help me ??

import pandas as pd

class Ogrenciler():
    def __init__(self , OgrNo=None , Ad =None , Soyad =None , Vize1 =None  , Vize2 =None , Final =None ):
        self.OgrNo=OgrNo
        self.Ad=Ad
        self.Soyad = Soyad
        self.Vize1 = Vize1
        self.Vize2 = Vize2
        self.Final = Final

csvVeri = pd.read_csv("Ogrenciler.csv")
for satir in csvVeri:
    Ogrenci=Ogrenciler()
    sutun=satir.split(',')
    Ogrenci.OgrNo=sutun[0]
    Ogrenci.OgrNo=sutun[1]
    Ogrenci.OgrNo=sutun[2]
    Ogrenci.OgrNo=sutun[3]
    Ogrenci.OgrNo=sutun[4]
    Ogrenci.OgrNo=sutun[5]