BaşlayınÜcretsiz başlayın

Handling missing JSON values

While merging employee data, you notice some records have incomplete information marked as "N/A". Before analysis, you need to identify these gaps and handle them properly.

Tablesaw can be configured to recognize custom placeholders as missing values, allowing you to detect and filter incomplete records.

The JsonReader, JsonReadOptions, and Table classes have been imported for you.

Bu egzersiz, kursun bir parçasıdır

Importing Data in Java

Kursa Göz Atın

Egzersiz talimatları

  • Configure the JSON options to treat "N/A" as a missing value.
  • Load the employee data into a table.
  • Filter for rows with missing department values.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

public class MissingValues {
    public static void main(String[] args) {
        // Configure "N/A" as missing
        JsonReadOptions options = JsonReadOptions
            .builder("employees_missing.json")
            .____("N/A")
            .build();
        
        // Load employee data
        Table employees = new ____().read(options);
        System.out.println("All employees:");
        System.out.println(employees);
        
        // Filter for missing department
        Table missingDept = employees.where(
            employees.stringColumn("department").____()
        );
        
        System.out.println("\nEmployees with missing department:");
        System.out.println(missingDept);
    }
}
Kodu Düzenle ve Çalıştır