Guest User

Guest User

  • Tech Writer
  • 77
  • 1.3k

import data from csv file into postgreSQL

Jul 14 2020 3:12 AM
Hi, I need help to import data from CSV file into PostgreSQL
 
In the code below, it will open the CSV file and read the data line by line.
 
 foreach (string path in Directory.EnumerateFiles(@"C:\ipub\root", "*.csv"))
 {
   string[] lines = System.IO.File.ReadAllLines(path);
   foreach (string line in lines)
 {
   Console.WriteLine(line);
 }
 }
 
The question is how to import all the data into the database after it already read?
 
This application doesn't have a button to upload the CSV file.
 
thank you
I'm using visual studio 2019, c#

Brought to you by:

Answers (2)