python csv obtain a line or a column of text data

. 1  # Coding = 'UTF-. 8' 
2  
. 3  Import CSV
 . 4  
. 5  # use List, only read column, and read the full text, CSV csv.reader will automatically generate content array 
. 6  '' ' 
. 7  DF = CSV. Reader (Open ( 'F.: \ c_database \ c2015.csv'))
 . 8  for Data in DF:
 . 9      Print (Data [. 3])
 10  '' ' 
. 11  
12 is  # If a row to be read, the content must be generated CSV DICT Dictionary (2-dimensional) 
13 is with Open ( ' F.: \ c_database \ c2015.csv ' , ' R & lt ' ) AS csvFile:
 14          Reader = csv.DictReader (csvFile)
 15          for row in reader:
16                 if row['日期']  ==  '20150105':
17                     print (row)

 

Guess you like

Origin www.cnblogs.com/sub2020/p/11206689.html