Example #1
0
        static void InsertAllReposCsvToDB(string dbPath, string csvPath)
        {
            var fileNames = CsvFile.GetAllFilenames(csvPath, "csv");

            foreach (var file in fileNames)
            {
                var table = "Acta_" + Path.GetFileNameWithoutExtension(file);
                table = table.Replace('.', '_');
                InsertRepoCsvToDB(dbPath, table, file);
            }
        }
Example #2
0
        static void FilesList(string path, string extension, bool withoutExtension = true)
        {
            var files = CsvFile.GetAllFilenames(path, extension);
            int i     = 0;

            foreach (var file in files)
            {
                string fileName = withoutExtension ?
                                  Path.GetFileNameWithoutExtension(file) :
                                  Path.GetFileName(file);
                System.Console.WriteLine($"{++i}) {file} - {fileName}");
            }
        }
Example #3
0
        static IEnumerable <string> GetFileNames(string path, string extension, bool withoutExtension = true)
        {
            var listFiles = new List <string>();
            var files     = CsvFile.GetAllFilenames(path, extension);

            foreach (var file in files)
            {
                string fileName = withoutExtension ?
                                  Path.GetFileNameWithoutExtension(file) :
                                  Path.GetFileName(file);
                listFiles.Add(fileName);
            }
            return(listFiles);
        }
Example #4
0
        static void BulkInsertAllTrepCsvToPg(string trepCsvPath, string schema = "raw_reports")
        {
            var files = from n in CsvFile.GetAllFilenames(trepCsvPath) orderby n
                        where Path.GetExtension(n) == ".csv" select n;

            System.Console.WriteLine($"*** Insertando csv files from {trepCsvPath}");
            System.Console.WriteLine();
            int i = 0;

            foreach (var file in files)
            {
                System.Console.WriteLine($"*** Procesando archivo #{++i} ...");
                BulkInsertTrepCsvToPg(file, schema);
                System.Console.WriteLine($"*** Archivo #{i} procesado...");
                System.Console.WriteLine();
            }
            System.Console.WriteLine($"*** Procesados en total {i} archivos!");
        }
Example #5
0
        static void FilesExcelToCsv(string excelPath, string csvPath)
        {
            var filesXlsx = CsvFile.GetAllFilenames(excelPath, "*.xlsx");
            int i         = 0;

            foreach (var filex in filesXlsx)
            {
                string fileName  = Path.GetFileNameWithoutExtension(filex);
                string fileNameX = Path.GetFileName(filex);
                string filec     = Path.Combine(csvPath, fileName + ".csv");
                string fileNameC = Path.GetFileName(filec);

                if (!File.Exists(filec))
                {
                    System.Console.WriteLine($"{++i}) {fileNameX} - {fileNameC}");
                    CsvFile.ExcelToCSVFile(filex, filec);
                    // System.Console.WriteLine($"{++i}) {filex} - {fileName} - {filec}");
                }
            }
        }