Search code examples
pythonpandasloopscsvindexing

Access individual values from a csv file, using their row and column indexes


I have a csv file with 100 rows and 100 columns,as shown. The values are all float type numbers. I am trying to write a loop where it will access each value, compare it with some divisions and sort. What is the code to access value from a particular index?

enter image description here

while col<=100:
    row=0
    while row<=100:
        dist=distf.1[row]
        if else loop
        row=row+1
    col=col+1`

something that does this.


Solution

  • You can use enumerate() function: https://stackoverflow.com/a/16139758/19949392

    Or pandas library: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.iloc.html