nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Burgess <mattyb...@gmail.com>
Subject Re: Convert CSV File to JSON
Date Wed, 03 May 2017 19:56:15 GMT
If all the CSV files had the same number of columns, you might be able to use ExtractText ->
SplitText -> ReplaceText to achieve this. However since your CSV files will have different
column names, I will assume that there can be a different number of columns per file.

In the upcoming NiFi 1.2.0 release I believe you'll be able to use ConvertRecord for this,
with a CSV reader and a JSON writer. In the meantime, if you are familiar with a scripting
language such as Groovy, JavaScript, Python/Jython, Lua, JRuby, or Clojure you can use ExecuteScript
for this. I have an example [1] of using Groovy to split a pipe-delimited file, it could be
altered to use commas and to write out JSON instead.

Regards,
Matt

[1] http://funnifi.blogspot.com/2016/02/executescript-explained-split-fields.html


> On May 3, 2017, at 1:07 PM, "suman.das@cuddle.ai" <suman.das@cuddle.ai> wrote:
> 
> Hi ,
> I have a csv file which is provided by client having different column name.
> I wanted to covert the csv contents to JSON.
> 
> Please advice
> 
> 
> 
> --
> View this message in context: http://apache-nifi-developer-list.39713.n7.nabble.com/Convert-CSV-File-to-JSON-tp15643.html
> Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.

Mime
View raw message