Skip to content

Commit 99804c7

Browse files
Add schema inference feature section and code example
Introduced a new feature card highlighting schema inference capabilities, and added a corresponding code tab and code example demonstrating how to infer SQL Server column types from CSV data. This update improves documentation of schema inference options and usage.
1 parent 3ba885d commit 99804c7

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

csv.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,14 @@ <h3>Progress & Cancellation</h3>
935935
<h3>Database-First Design</h3>
936936
<p>Built specifically for database import workflows. Culture-aware parsing, null vs empty handling, and direct integration with ADO.NET.</p>
937937
</div>
938+
939+
<div class="feature-card">
940+
<div class="feature-icon">
941+
<i class="fa-solid fa-wand-magic-sparkles"></i>
942+
</div>
943+
<h3>Schema Inference</h3>
944+
<p>Automatically detect optimal SQL Server column types from CSV data. Sample-based (fast) or full-scan (zero risk) modes with progress reporting.</p>
945+
</div>
938946
</div>
939947
</section>
940948

@@ -949,6 +957,7 @@ <h2>Simple, Powerful API</h2>
949957
<div class="code-tabs">
950958
<button class="code-tab active" onclick="showCode('basic')">C# Basic</button>
951959
<button class="code-tab" onclick="showCode('bulk')">SqlBulkCopy</button>
960+
<button class="code-tab" onclick="showCode('schema')">Schema Inference</button>
952961
<button class="code-tab" onclick="showCode('compressed')">Compressed</button>
953962
<button class="code-tab" onclick="showCode('parallel')">Parallel</button>
954963
<button class="code-tab" onclick="showCode('errors')">Error Handling</button>
@@ -1022,6 +1031,41 @@ <h2>Simple, Powerful API</h2>
10221031
<span class="type">Console</span>.<span class="method">WriteLine</span>(<span class="string">$"Imported </span>{reader.CurrentRecordIndex}<span class="string"> rows"</span>);</code></pre>
10231032
</div>
10241033

1034+
<div class="code-block" id="code-schema">
1035+
<div class="code-header">
1036+
<div class="code-dots">
1037+
<span class="code-dot red"></span>
1038+
<span class="code-dot yellow"></span>
1039+
<span class="code-dot green"></span>
1040+
</div>
1041+
<span class="code-filename">SchemaInference.cs</span>
1042+
<button class="code-copy" onclick="copyCode('schema')">
1043+
<i class="fa-regular fa-copy"></i>
1044+
</button>
1045+
</div>
1046+
<pre><code><span class="keyword">using</span> <span class="type">Dataplat.Dbatools.Csv.Reader</span>;
1047+
1048+
<span class="comment">// Fast: Sample first 1000 rows (tiny risk if data changes later)</span>
1049+
<span class="keyword">var</span> columns = <span class="type">CsvSchemaInference</span>.<span class="method">InferSchemaFromSample</span>(<span class="string">"data.csv"</span>);
1050+
1051+
<span class="comment">// Safe: Scan entire file with progress reporting (zero risk)</span>
1052+
<span class="keyword">var</span> columns = <span class="type">CsvSchemaInference</span>.<span class="method">InferSchema</span>(<span class="string">"data.csv"</span>, <span class="keyword">null</span>, progress => {
1053+
<span class="type">Console</span>.<span class="method">WriteLine</span>(<span class="string">$"Progress: </span>{progress:P0}<span class="string">"</span>);
1054+
});
1055+
1056+
<span class="comment">// Generate CREATE TABLE statement</span>
1057+
<span class="keyword">string</span> sql = <span class="type">CsvSchemaInference</span>.<span class="method">GenerateCreateTableStatement</span>(columns, <span class="string">"MyTable"</span>);
1058+
<span class="comment">// CREATE TABLE [dbo].[MyTable] (</span>
1059+
<span class="comment">// [Id] int NOT NULL,</span>
1060+
<span class="comment">// [Name] nvarchar(100) NULL,</span>
1061+
<span class="comment">// [Price] decimal(10,2) NOT NULL,</span>
1062+
<span class="comment">// [Created] datetime2 NULL</span>
1063+
<span class="comment">// );</span>
1064+
1065+
<span class="comment">// Detected types: uniqueidentifier, bit, int, bigint,</span>
1066+
<span class="comment">// decimal(p,s), datetime2, varchar(n), nvarchar(n)</span></code></pre>
1067+
</div>
1068+
10251069
<div class="code-block" id="code-compressed">
10261070
<div class="code-header">
10271071
<div class="code-dots">

0 commit comments

Comments
 (0)