May-22-2020, 04:51 AM
how to read a specific row in CSV file ?
[split] how to read a specific row in CSV file ?
|
May-22-2020, 04:51 AM
how to read a specific row in CSV file ?
Want to read the specific row number or what is the criteria?.
Use pandas to readcsv, output will be dataframe. Using dataframe we can add multiple criteria to fetch required rows. import pandas as pd ot = pd.read_csv(r'Values.csv') print("Full data",ot) #Select specific columns of your dataframe print(ot['name']) #select values based on criteria print(ot[ot.name == 'an'])Let me know if your requirement is different.
CSV is not random access, so you must read sequentially in a loop
if that loop is enumerated, you can generate the row number (index actually) https://docs.python.org/3/library/functi...#enumerate |
|