Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

read specific rows from csv in python

You could use a list comprehension to filter the file like so:

with open('file.csv') as fd:
    reader=csv.reader(fd)
    interestingrows=[row for idx, row in enumerate(reader) if idx in (28,62)]
# now interestingrows contains the 28th and the 62th row after the header
Comment

PREVIOUS NEXT
Code Example
Python :: fixed precision float python 
Python :: conda env 
Python :: Python Program to count the number of lowercase letters and uppercase letters in a string. 
Python :: pandas apply function on two columns 
Python :: remove element from list python 
Python :: python glob all files in directory recursively 
Python :: pandas slicing from one column to another 
Python :: python create list from range 
Python :: tkinter yes no dialogue box 
Python :: loop through list of tuples python 
Python :: failed to allocate bitmap 
Python :: 2 distinct numbers random number generator python 
Python :: Django less than and greater than 
Python :: assign python 
Python :: date colomn to datetime 
Python :: cant install tensorflow pip python 3.6 
Python :: import error in same directory python 
Python :: create spark dataframe from pandas 
Python :: python logger get level 
Python :: how to create a tuple from csv python 
Python :: django objects.create() 
Python :: where to find location of where python is installed linux 
Python :: Set a random seed 
Python ::  in python 
Python :: pandas pad method 
Python :: keras example 
Python :: np argmin top n 
Python :: import time in python 
Python :: python check for duplicate 
Python :: python push to list 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =