Code Explainers

Code explainers tagged #file-io

java
public List<Employee> parseEmployees(Path csvPath) throws IOException {
    List<Employee> employees = new ArrayList<>();
 
    try (BufferedReader reader = Files.newBufferedReader(csvPath, StandardCharsets.UTF_8)) {

Parsing a CSV into typed objects in Java

csv-parsing file-io try-with-resources
Intermediate 7 steps
java
package com.example.logs;
 
import java.io.IOException;
import java.io.UncheckedIOException;

Counting HTTP statuses with Java streams

streams regex file-io
Intermediate 6 steps
php
<?php
 
declare(strict_types=1);
 

Streaming file lines with a PHP generator

generators lazy-evaluation file-io
Intermediate 7 steps
python
import gzip
from pathlib import Path
from typing import Iterator
 

Streaming TSV records with Python generators

generators lazy-evaluation file-io
Intermediate 5 steps
go
package main
 
import (
	"bufio"

Counting matching lines in Go with bufio

file-io buffered-scanning error-handling
Intermediate 4 steps