I am reading file with CSV file with Spark SQL Context.
Code :
m.put("path", CSV_DIRECTORY+file.getOriginalFilename());
m.put("inferSchema", "true"); // Automatically infer data types else string by default
m.put("header", "true"); // Use first line of all files as header
m.put("delimiter", ";");
DataFrame df = sqlContext.load("com.databricks.spark.csv",m);
df.printSchema();
Fetching Column names and Data type with df.printSchema()
O/P :
|--id : integer (nullable = true)
|-- ApplicationNo: string (nullable = true)
|-- Applidate: timestamp(nullable = true)
What is the return type of the statement printSchema. How to convert the output in JSON format, How to convert data frame into JSON??
Desired O/P:
{"column":"id","datatype":"integer"}