Thursday, 4 June 2020
CSV Iterator
package com.css;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.json.simple.JSONObject;
import com.fasterxml.jackson.databind.MappingIterator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.csv.CsvMapper;
import com.fasterxml.jackson.dataformat.csv.CsvSchema;
import com.fasterxml.jackson.dataformat.csv.impl.CsvReader;
public class JSONUtilities {
static File csvFile = new File("d:\\sapient\\sample.csv");
static File jsonFile = new File("d:\\sapient\\sample.csv.json");
// JDBC driver name and database URL
static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
static final String DB_URL = "jdbc:oracle:thin:@localhost:1521:orcl";
// Database credentials
static final String USER = "system";
public static void main(String[] args) throws Exception {
convertCSVToJSON(csvFile);
}
public static void convertCSVToJSON(File csvFile) throws IOException {
CsvSchema bootstrap = CsvSchema.emptySchema().withHeader().withoutEscapeChar();
CsvMapper csvMapper = new CsvMapper();
MappingIterator
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment