You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Austin Duncan <ad...@pyaanalytics.com> on 2018/01/30 21:44:14 UTC

adding a filename column to a csv to insert into a table

all,
I am trying to take a csv, add a column to it that contains the filename of
the csv, and then insert that record into postgres using the
putdatabaserecord processor. Any idea what would be the best way to go
about doing this?

-- 
​Austin Duncan
*​Researcher​*

PYA Analytics
2220 Sutherland Avenue
<https://maps.google.com/?q=2220+Sutherland+AvenueKnoxville,+TN+37919+865&entry=gmail&source=g>
Knoxville, TN 37919
<https://maps.google.com/?q=2220+Sutherland+AvenueKnoxville,+TN+37919+865&entry=gmail&source=g>
423-260-4172
<https://maps.google.com/?q=2220+Sutherland+AvenueKnoxville,+TN+37919+865&entry=gmail&source=g>
<%28865%29%20684-2828>

Re: adding a filename column to a csv to insert into a table

Posted by Koji Kawamura <ij...@gmail.com>.
Hi Austin,

I think there are a couple of ways to do that:
1. UpdateRecord with CSVReader and CSVWriter, update a column with a
Record Path and Expression Language, e.g. Add a dynamic property,
key=/filename, value=${filename}
2. Use SpritText to sprit each CSV record into a FlowFile, then
combine ReplaceText to prepend, append or replace text to insert
filename, you can use Expression Language here, too

I recommend #1 above as it performs better than #2. It may take time
for you to get familiar with Record, Record path, Reader, Writer,
Schema ... etc, if you haven't played with those yet, but once you
know how it woks, you can apply the Record processing at various
processors.

Hope this helps,
Koji


On Wed, Jan 31, 2018 at 6:44 AM, Austin Duncan <ad...@pyaanalytics.com> wrote:
> all,
> I am trying to take a csv, add a column to it that contains the filename of
> the csv, and then insert that record into postgres using the
> putdatabaserecord processor. Any idea what would be the best way to go about
> doing this?
>
> --
> Austin Duncan
> Researcher
>
> PYA Analytics
> 2220 Sutherland Avenue
> Knoxville, TN 37919
> 423-260-4172