- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
INSERT CSV DATA INTO MSSQL DB
Created ‎02-09-2022 05:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have many zip files each containing a csv file. The header of the csv file contain fields and some field names have space between words e.g "field one" instead of "field_one" which is the one in the database.
Please, what is the optima method to change the csv field names to match the ones in the database.
NOTE: I am using MSSQL as the DB. And my NIFI implementation is
1) GetFile : from a repository that contain zip files of very large size
2)UnpackContent: to extract the csv from the zipped file
3) PutDabaseRecord: to persist the csv data into db because of its large size.
Thank you for your kind help.
Created ‎02-09-2022 08:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use a QueryRecord processor before the PutDatabaseRecord.
You can add a relation to the QueryRecord processor with the following associated query:
select
"field one" as field_one,
"field two" as field_two,
"field three" as field_three
from flowfile
In the query above you can reference one field names using double-quotes if they have spaces. You can specify an alias for that column, which is the field name that will be used in the output.
Cheers,
Andre
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Created ‎02-09-2022 08:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use a QueryRecord processor before the PutDatabaseRecord.
You can add a relation to the QueryRecord processor with the following associated query:
select
"field one" as field_one,
"field two" as field_two,
"field three" as field_three
from flowfile
In the query above you can reference one field names using double-quotes if they have spaces. You can specify an alias for that column, which is the field name that will be used in the output.
Cheers,
Andre
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.