Python read dedicated rows from csv file
<p>need some help to read dedicated rows in python. The txt file content is defined as the following:</p>

<pre><code>A;Maria;1.5;20.0;FFM; 
B;2016;20;1;2017;20;1; 
</code></pre>

<p>I read the file n python as defined below:</p>

<pre><code>import csv

with open('C:/0001.txt', newline='') as csvfile:
    filereader = csv.reader(csvfile, delimiter=' ')
    for row in filereader :
        print('; '.join(row))
</code></pre>

<p>What I am not sure about it is how can I read the first row based on the first Character </p>

<blockquote>
  <p>A</p>
</blockquote>

<p>and fill every value in an own function.</p>

<p>Then the second row identified based on </p>

<blockquote>
  <p>B</p>
</blockquote>

<p>fill every value in an own function etc.</p>

<p>Thanks</p>

<p>Thanks for the answers. I defined a class and want to fill every value to the dedicated function:</p>

<pre><code>class Class(object):

    def __init__(self, name, years, age, town):
        self.name = name
        self.years = years
        self.age = age
        self.town = town

    def GetName(self):
        return self.name

    def GetYears(self):
        return self.years

    def GetAge(self):
        return self.age

    def GetTown(self):
        return self.town    

    def __str__(self):
        return "%s is a %s" % (self.name, self.years, self.age, self.town)
</code></pre>

<p>So my file reader should load the file read a line and fill the dedicated values into the function as shown below. I am just not sure how to call the reader for the first row based on A and the fill the function:</p>

<pre><code>import csv

with open('C:/0001.txt', newline='') as csvfile:
    spamreader = csv.reader(csvfile, delimiter=';')
    for row in spamreader:
        FirstRow = row[0]
        if FirstRow == 'A':
           **Fill Maria into GetName
           Fill 1.5 into GetYears
           Fill 20.0 into GetAge
           Fill FFM into GetTown**
</code></pre>

python