-1

I have multiple csv file for example 1.csv,2.csv,3.csv then I want to create each csv file new tables in my postgres database.

currently im using "get file names" to read my folder that contains multiple csv files, then im using "CSV file input" to read the multiple csv files. After that I not sure what function should I use to save/create new tables in my postgres database.

What step I should use ?

I already try to use table output but doesnt work for me. Im not sure maybe there some wrong setting I configure.

I expect that I will have multiple tables in my postgres base on my csv file name.

SharkJr
  • 1
  • 2

2 Answers2

1

Not exactly sure what you want to accomplish, but there are diffrent ways to do this.

You can approach this by setting up a "csv file input" step for each csv, and by sending the result to a "table output" step.

A more complex but nicer sollution would be to read out the header of the csv first, and then based on the filename and the header list have a metadata-injected proces where you create a table (named after file) with columns based on the headernames (all text, since you don't know the type) and then load the csv (columns named after headers), after which you insert the fields from the result (headernames) into the fields in the table (named after file) with it's columns (also headernames). Then you can just insert any number of csvs into this and they will all just end up in your database.

Bert-Jan Stroop
  • 357
  • 1
  • 10
0

I usually create the table in postgres (with no columns), with the table created, the table output will add the columns and insert the values with no issues.

maybe it's not the most eficient method, but creating few tables should not be a big problem in terms of time and complexity...postgres in some pentaho versions do have a difficult to create tables.

ThiagoM
  • 39
  • 4