Tablesaw के साथ CSV प्रोसेसिंग

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

Anthony Markham

VP Quant Developer

CSV फाइलें पढ़ना

  • read().csv() से CSV फाइलें पढ़ें
import tech.tablesaw.api.Table;
// Read in data
Table dataTable = Table.read().csv("data.csv");
  • कॉलम टाइप अपने-आप पहचानकर structured Table ऑब्जेक्ट बनता है 💡
Java में डेटा इम्पोर्ट करना

CSV पढ़ने के विकल्प

  • अधिक कंट्रोल के लिए CsvReadOptions का उपयोग करें
import tech.tablesaw.io.csv.CsvReadOptions;
CsvReadOptions options = CsvReadOptions.builder("data.csv")

.separator(';') // Use semicolon as delimiter
.header(true) // First row contains headers
.missingValueIndicator("N/A") // Treat "N/A" as missing data
.build();
// Load the table using the custom options Table table = Table.read().csv(options);
Java में डेटा इम्पोर्ट करना

CSV फाइलें लिखना

  • बेसिक CSV एक्सपोर्ट के लिए write().csv() का उपयोग करें
  • Table क्लास से इम्पोर्ट हुआ
  • कॉलम टाइप और संरचना बनी रहती है
  • स्पेशल कैरैक्टर अपने-आप हैंडल होते हैं
// Write dataTable to output.csv
dataTable.write().csv("output.csv");
Java में डेटा इम्पोर्ट करना

CSV लिखने के विकल्प

  • लिखने के विकल्प तय करने के लिए CsvWriteOptions का उपयोग करें
CsvWriteOptions writeOptions = CsvWriteOptions
    .builder("output.csv")

.header(true) // Include column headers
.separator(';') // Use semicolon delimiter
.quoteAlways(true) // Quote all fields
.lineEnd("\r\n") // Windows-style line endings
.build();
// Write the CSV using the custom options
Table.write().csv(writeOptions);
Java में डेटा इम्पोर्ट करना

CSV वर्कफ़्लो

  • पूर्ण वर्कफ़्लो: read -> inspect -> process -> write
  • नॉन-डिस्ट्रक्टिव ऑपरेशन (नई फाइलें बनती हैं) 📁
// Read CSV, modify, and write back
Table students = Table.read().csv("students.csv");

// View structure
System.out.println(students.structure());

// Save as new file
students.write().csv("students_processed.csv");
Java में डेटा इम्पोर्ट करना

अभ्यास करते हैं!

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

Preparing Video For Download...