How to find largest number in file and see on which line it is
<p>The file looks like this:</p>

<pre><code>1, a b
2, c d
3, e f
</code></pre>

<p>my current code </p>

<pre><code>b = open('file.txt', 'r')

c = b.readlines()
regels = len(c)

print(regels)
</code></pre>

<p>I got the numbers of lines but still need biggest number + on which line it is. </p>

<p>You need loop over each line in file, parse each line and find the largest number.</p>

<p>I do not quite understand how the numbers are stored in your file. Just assuming that in each line, the first field are numeric and separate with others (non-numeric) by <code>','</code>. And I assume all numbers are integer.</p>

<pre><code>ln = 0
maxln = 0
maxn = 0
with open(filename, 'r') as f:
    line = f.next()
    if line:
       ln = 1
       maxln = 1
       maxn = int(line.split(",")[0].strip())
    else:
       raise Exception('Empty content')
    for line in f:
        ln += 1
        cur = int(line.split(",")[0].strip())
        if cur &gt; maxn:
            maxn = cur
            maxln = ln
</code></pre>

<p>ln is used to record current line number, maxn is used to record current maximum number, and maxln is used to record current maximum number location.</p>

<p>One thing you need to do is fetch the first line to initialize these variables.</p>

python