LogoLogo
HomePricingDocumentation
  • 💿Getting Started
    • Installation and Project Setup
    • Hello Perigee!
    • Perigee Application Design
    • Hello Configuration
    • Hello Logs
    • Hello Integration
    • Troubleshooting
    • Case Studies
  • 📃License + Notice
    • 📂Licensing
    • Notice of Third Party Agreements
  • 🚀Perigee and Beyond
    • Extending - Threads
    • Extending - Loaders
    • ⏳All about CRON
  • 🔮API Generation
    • What is API Generation?
    • API Builder
  • 🗺️Architecting YOUR App
    • Design and Requirements
    • Define Sources
    • Requirements
  • 🧩Core Modules
    • 🌐PerigeeApplication
    • 🪡Thread Registry
    • Event Sources
      • Scheduled/Logic
        • CRON Thread
        • Scheduler
        • Sync Agent
      • Watchers
        • SalesForce
        • Sharepoint
        • Directory Watch
        • Directory Notifier
        • IMAP
    • Credential Management
      • Connection Strings
      • Custom Refresh Logic
      • RestSharp Authenticator
      • Credential Store SDK
      • ⁉️Troubleshooting Credentials
    • Integration Utilities
      • HTTP(S) - RestSharp
      • Transaction Coordinator
      • Limiter
      • Watermarking
    • Alert Managers
      • SMS
      • Email
      • Discord
      • Teams
    • File Formats
      • Excel
      • CSV
    • 📁File System Storage
      • File Revision Store
      • Concurrent File Store
      • FileSync + Cache
    • Third Party
      • SmartSheets
      • Microsoft Graph
    • Perigee In Parallel
      • Parallel Processing Reference
      • Extensions
      • GroupProcessor
      • SingleProcessor
    • 🧱Utility Classes
      • Metrics
      • F(x) Expressions
      • Multi-Threaded Processor (Scatter Gather)
      • OpenAI - GPT
      • XML Converter
      • Dynamic Data Table
      • Debounce
      • Thread Conditions
      • Perigee Utility Class
      • Network Utility
      • Lists
      • FileUtil
      • Inclusive2DRange
      • Strings, Numbers, Dates
      • Nested Sets
      • Behavior Trees
      • JsonCompress
      • Topological Sorting
      • DBDownloader
    • 🈁Bit Serializer
  • 📣Examples and Demos
    • API + Perigee
    • 📰Excel Quick Load
    • SalesForce Watcher
    • Report Scheduler
    • Agent Data Synchronization
    • 📩IMAP Echo bot
    • Watch and load CSVs
    • Graph Delegated Authorization + DataVerse
    • Coordinator Demo
    • Azure Service Bus
    • QuickBooks Online
  • 📘Blueprints
    • Perigee With .NET Hosting
    • Web Host Utilities
    • 🔌Plugin Load Context
  • 🎞️Transforms
    • 🌟What is Transforms?
    • 📘Terminology
    • 🦾The Mapping Document
    • 👾Transformation Process
    • 😎Profile
    • 🎒Automation
      • 🕓Package Options
      • 🔳Configuration
    • 🔧Utilities
      • 🧹Clean
      • 📑Map File
      • 🔎File Identification
      • 🗺️Map Generation
      • 🪅Insert Statement Generation
  • 🗃️Transform SDK
    • 👋Quick Start Guide
    • 🥳MapTo
    • 🔌Authoring Plugins
      • 🔘File IO Process
      • 📢Data Quality
      • 🟢Transform Process
    • SDK Reference
      • 🔘FileIOProcessData
      • 📢DataQualityContext
      • 🎛️TransformDataContext
      • 🏅TransformResult
Powered by GitBook
On this page
  • Data Load
  • The associated files:
Export as PDF
  1. Examples and Demos

Excel Quick Load

From Data To Analyst In a Few Clicks

PreviousAPI + PerigeeNextSalesForce Watcher

Last updated 2 years ago

Data Load

Need to take your Excel data and load it into your database to get the analysts started?

Instead of taking weeks to develop a new data pipeline, create structure, and work with the business to load your new client data in, just drop the file in Perigee. We will take care of everything from finding and getting the data loaded, to creating a table in only a few seconds. You’ll be a hero!

The Data

Here's a typical messed up Excel file where data is shifted and there are unwanted headers.

The Code

using Microsoft.Extensions.Logging;
using Perigee;
using Perigee.Database.MSSQL;
using Perigee.FileFormats.Excel;
using System.Data;

// Visit https://docs.perigee.software to learn more
// Visit https://perigee.software to purchase a license!
PerigeeApplication.ApplicationNoInit("Quick Data Loads", (c) => {

    //Register
    c.RegisterConnectionString("MSSQL", "main");

    //Read
    using MemoryStream ms = new MemoryStream(File.ReadAllBytes("SampleExcel.xlsx"));
    var dtex = ExcelReader.ReadDataTable(ms, "UserData", out var ddt, true, false, tablename: "clientData", schema: "dbo");

    //Print
    var stats = ddt.GetStatistics();
    c.GetLogger<Program>().LogInformation("Loaded {r} rows, header is on row {n}. Column names: {@c}. Fill Rate %: {Fill:N2}", dtex.Rows.Count, ddt.HeaderRow + 1, dtex.Columns.OfType<DataColumn>().Select(f => f.ColumnName).ToArray(), (stats.FillRate?.Average(f => f.Value) ?? 0.0m) * 100.0m);
    foreach (var col in stats?.FillRate?.Reverse() ?? Array.Empty<KeyValuePair<uint, decimal>>())
    {
        c.GetLogger<Program>().LogInformation("{Column} fill rate %: {fr}", stats!.ColumnNames[col.Key], col.Value * 100.0m);
    }

    //Load, create or drop.
    MSSQLProcessUtilities.ProcessToSQL(dtex, "MSSQL", true, new SQLTableColumnDefaults() { StringType = SqlDbType.NVarChar }, DropTableIfNotExists: true);
    
});

After running the application, you'll see the log showing how many rows it found, where the header was since it wasn't on the top row, and the column's detected. It even prints out the fill rates per column!

Taking a peak at our database, we see the data loaded into our new table dbo.clientData:

Which came directly from the Excel file linked below

The associated files:

The appsettings.json file:

{
  "ConnectionStrings": {
    "main": "data source=host; initial catalog=test; User Id=sa; Password=abc"
  },
  "AppSettings": {
  
  },
  "Perigee": { "HideConsole": false },
  "Serilog": {
    "MinimumLevel": "Debug",
    "WriteTo": [
      { "Name": "Console" }
    ]
  }
}

The SampleExcel file we loaded:

📣
📰
11KB
SampleExcel.xlsx
Excel window showing misaligned data
Results, showing statistics
Page cover image