mirror of
				https://gitlab.com/akasroua/covot
				synced 2025-11-04 02:39:50 +01:00 
			
		
		
		
	Implement CSV reader
This commit is contained in:
		
							parent
							
								
									1504ccc3fe
								
							
						
					
					
						commit
						5a3afd0bfa
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1 +1,2 @@
 | 
			
		||||
src/constants.py
 | 
			
		||||
data
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								src/database.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/database.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
from csv import DictReader
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def find_user(reader, id):
 | 
			
		||||
    for row in reader:
 | 
			
		||||
        if row["numero_de_documento"] == id or row["correo_institucional"] == id:
 | 
			
		||||
            return row
 | 
			
		||||
    raise Exception("Error: User not found")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def search_csv(filepath, id):
 | 
			
		||||
    with open(filepath) as csvfile:
 | 
			
		||||
        reader = DictReader(csvfile)
 | 
			
		||||
        user = find_user(reader, id)
 | 
			
		||||
        return user
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user