nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Payne <marka...@hotmail.com>
Subject Re: getFile Content as json element
Date Thu, 02 Jun 2016 14:42:18 GMT
Sven,

With Regex, I forgot that the . character does not match end-of-line characters. So you'll
end up with the output like
you described below. You should be okay, though, if you change the regex to (?s:.+)

This indicates that you want to use "dot-all" mode so that the . character will match end-of-line
characters as well.

Thanks
-Mark


> On Jun 2, 2016, at 10:22 AM, Sven Davison <svendavison@gmail.com> wrote:
> 
> I tried this yesterday.. tried a couple diffrent things. it looks like it's doing it
line by line instead of as a batch.. so if i have 3 lines in my file i have something like
this.
> 
> {
>   filename: "${filename}",
>   fileTime: ${now()},
>   content: [
>        first line of file
>   ]
> }
> 
> 
> {
>   filename: "${filename}",
>   fileTime: ${now()},
>   content: [
>        second line of file
>   ]
> }
> 
> 
> {
>   filename: "${filename}",
>   fileTime: ${now()},
>   content: [
>        third line of file
>   ]
> }
> 
> 
> On Wed, Jun 1, 2016 at 2:02 PM, Mark Payne <markap14@hotmail.com <mailto:markap14@hotmail.com>>
wrote:
> Sven,
> 
> Have you had a look at the ReplaceText processor? You could use the Regular Expression
(.+) to match the entire content
> of the FlowFile and then replace it with something like:
> 
> {
>   filename: "${filename}",
>   fileTime: ${now()},
>   content: [
>     $1
>   ]
> }
> 
> The $1 is a back-reference that will reference whatever is in the first capturing group
of your Regular Expression (in this case,
> the entire content of the FlowFile).
> 
> Thanks
> -Mark
> 
> 
> > On Jun 1, 2016, at 1:10 PM, Sven Davison <svendavison@gmail.com <mailto:svendavison@gmail.com>>
wrote:
> >
> > i've got a flow where i'm reading a file and setting various attributes. now i want
to wrap the content of the origional file into a "content" element w/in my JSON object.
> >
> > this is invalid json but you'll get the idea.
> >
> > { filename: "somefile",
> >  fileTime: blahSomeDateString
> >  content:[
> >      need content from origional file here.
> >   ]
> > }
> >
> >
> > right now i can get eaither the content.. OR the other properties. How do i combine
them?!
> >
> >
> >
> > -Sven
> 
> 


Mime
View raw message