Hi Guys,
Below is my code snippet , which read all csv files under the given folder
row by row but my requirement is to read csv file at a time and convert as
json which will looks like :
{"A":"1","B":"3","C":"4","D":9}
Csv file data format :
-------------------------------
*field_id,data,*
*A,1B,3C,4D,9*
Code snippet:
--------------------------
*final StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();String path =
"s3://messages/data/test/dev/2020-12-07/67241306/";TypeInformation[]
fieldTypes = new TypeInformation[]{ BasicTypeInfo.STRING_TYPE_INFO,
BasicTypeInfo.STRING_TYPE_INFO};RowCsvInputFormat csvFormat = new
RowCsvInputFormat( new Path(path),
fieldTypes);csvFormat.setSkipFirstLineAsHeader(true);csvFormat.setNestedFileEnumeration(true);DataStream<Row>
lines = env.readFile(csvFormat, path, FileProcessingMode.PROCESS_ONCE,
-1);lines.map(value -> value).print();*
Any help is highly appreciated.
Thanks,
-Deep