-2

I am working on a tracking project in which I am implementing trilateration algorithm. I have data in csv file. I want to retrieve values of cells in csv file one by one in my algorithm. Following is the screenshot of dataset for reference. enter image description here

For example: At first (see picture above) I have to retrieve '-49' then '-51' and then '-56' and so on I have to retrieve all the values. Is there any shortcut method through loop to do this efficiently.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Muhammad Ali
  • 1
  • 1
  • 4
  • have you checked `csv` module or `pandas` ? – Epsi95 Mar 02 '21 at 13:03
  • 2
    What did you search for, and what did you find? What did you try, and how did it fail? Reading CSV files is a very common question here; please search before asking. – tripleee Mar 02 '21 at 13:17

1 Answers1

0

With pandas library, you can retrieve columns as below and iterate over them with for loops.

import pandas as pd

data = pd.read_csv("datasetname.csv")

gateA = data['GateA']
gateB = data['GateB']
gateC = data['GateC']

for i in range(len(gateA)):
    first = gateA[i]
    second = gateB[i]
    third = gateC[i]
Dharman
  • 30,962
  • 25
  • 85
  • 135
Burhan Bilen
  • 83
  • 2
  • 7