mirror of
				https://github.com/pocketpy/pocketpy
				synced 2025-10-31 00:40:16 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			33 lines
		
	
	
		
			467 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			467 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| icon: package
 | |
| label: csv
 | |
| ---
 | |
| 
 | |
| ### `csv.reader(csvfile: list[str]) -> list[list]`
 | |
| 
 | |
| Parse a CSV file into a list of lists.
 | |
| 
 | |
| ### `csv.DictReader(csvfile: list[str]) -> list[dict]`
 | |
| 
 | |
| Parse a CSV file into a list of dictionaries.
 | |
| 
 | |
| ## Example
 | |
| 
 | |
| ```python
 | |
| import csv
 | |
| 
 | |
| data = """a,b,c
 | |
| 1,2,3
 | |
| """
 | |
| 
 | |
| print(csv.reader(data.splitlines()))
 | |
| # [
 | |
| #    ['a', 'b', 'c'],
 | |
| #    ['1', '2', '3']
 | |
| # ]
 | |
| 
 | |
| print(csv.DictReader(data.splitlines()))
 | |
| # [
 | |
| #    {'a': '1', 'b': '2', 'c': '3'}
 | |
| # ]
 | |
| ``` |