शुरू करेंमुफ़्त में शुरू करें

CSV parsing options को संभालना

कर्मचारी प्रदर्शन वाली फ़ाइल में मैनुअल डेटा एंट्री की गलतियों के कारण "N/A" वैल्यूज़ हैं. अगर इम्पोर्ट के समय इन्हें नहीं संभाला गया, तो ये missing वैल्यूज़ की बजाय टेक्स्ट स्ट्रिंग्स मानी जाएँगी, जिससे गलत कॉलम टाइप बनेंगे और कैलकुलेशन टूट सकते हैं. शुरुआत में ही missing value indicators को सही तरह पहचान लेना, बाद में कई घंटे की डीबगिंग से बचाता है.

Table और CsvReadOptions क्लास आपके लिए इम्पोर्ट कर दी गई हैं.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Java में डेटा इम्पोर्ट करना

पाठ्यक्रम देखें

अभ्यास निर्देश

  • defaultParsing की structure प्रिंट करें.
  • फ़ाइल को customParsing के रूप में लोड करें, जिसमें "N/A" को missing माना गया हो.
  • customParsing की structure प्रिंट करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

public class ParseCSVFiles {
    public static void main(String[] args) {
        try {
            Table defaultParsing = Table.read().csv("employee_performance.csv");
            System.out.println("Default parsing structure:");
            // Print the structure of defaultParsing
            System.out.println(defaultParsing.____);
            System.out.println(defaultParsing.first(3).print());

            // Load the file as customParsing with "N/A" handled as missing
            Table customParsing = Table.read().csv(
                ____.builder("employee_performance.csv")
                    .____(____)
                    .build()
            );

            System.out.println("\nCustom missing value parsing structure:");
            // Print the structure of customParsing
            System.out.println(customParsing.____);
            System.out.println(customParsing.first(3).print());

        } catch (Exception e) {
            System.err.println("Error reading CSV files: " + e.getMessage());
        }
    }
}
कोड संपादित करें और चलाएँ