TableToJsonlConverter 0.0.15
dotnet add package TableToJsonlConverter --version 0.0.15
NuGet\Install-Package TableToJsonlConverter -Version 0.0.15
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TableToJsonlConverter" Version="0.0.15" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TableToJsonlConverter" Version="0.0.15" />
<PackageReference Include="TableToJsonlConverter" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TableToJsonlConverter --version 0.0.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TableToJsonlConverter, 0.0.15"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TableToJsonlConverter@0.0.15
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TableToJsonlConverter&version=0.0.15
#tool nuget:?package=TableToJsonlConverter&version=0.0.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TableToJsonlConverter
Summary
以下の記事に影響を受けて作成しました。
Qiita - Snowflake Snowpipeを本番導入する前に読むやつ
ローカルのデータをJson Linesに簡単に変換することを目的としています。現時点では以下に対応しています。
- Excel
- CSV(or TSV)
- Microsoft SQL Server
- SQLite
Getting Started
Source Code
- Visual Studio 2022
- .NET 6.0
How to Use
エクセルからJsonLinesに変換する
string ifile = @"TestFiles\Excel\test_base.xlsx"; // input file path
bool headerf = true; // Whether the header is present
int scol = 1; // Start column Numboer (Numbers starting with 1)
int srow = 1; // Start row Numboer (Numbers starting with 1)
int chcol = 1; // The column number that must contain a value (the import ends where this value is missing)
int sheetno = 0; // Excel Sheet Index (Numbers starting with 0)
ZkExcelToJsonl test = new ZkExcelToJsonl(ifile, headerf, scol, srow, chcol, sheetno); // Initialize
test.Read(); // File Read
var header = test.GetHeader()!; // Get header Information
header.ForEach(col => { Console.WriteLine(col.Col + "->" + col.ColumnName); });
// output
// 1->header1
// 2->header2
// test ←LineBreak
// 3->header3
// 4->header4
Console.WriteLine(test.JsonLines);
// output
//{"header1": "https://www.premium-tsubu-hero.net/","header2\ntest": "Brow1","header3": "Cro w1","header4": "Drow1"}
// { "header1": "Arow2","header2\ntest": "Brow2","header3": "Crow2","header4": "A series of clinical trials have proven conclusively that the new medication is effective in treating the virus.\nBy the time she retired, the human resources director at Mycroft Enterprises had worked with the company for fifty years."}
// { "header1": "Arow3","header2\ntest": "Brow3","header3": "Crow3","header4": "Dro\"w\"3"}
// { "header1": "Arow4","header2\ntest": "Brow4","header3": "Cr,ow4","header4": "Drow4"}
// { "header1": "Arow5","header2\ntest": "Brow5","header3": "Crow5","header4": "Drow5"}
string ofile = @"TestFiles\test_base.xlsx.json";
// output Json Lines File
test.Write(ofile);
// outpu Json Lines .gz
test.CompressWrite(ofile);
Excel to Json Lines
var test = new ZkExcelToJsonl()
{
InputPath = @"C:\test.xlsx", // input file path for .xlsx
HeaderF = true, // hedder -> true:exist false:not exist
StartCol = 1, // start column -> 1~
StartRow = 1, // start row -> 1~
CheckCol = 1, // not null column -> 1~
SheetNo = 0 // excel sheet index -> 0~
};
test.Read();
string outpath = @"C:\test.json";
test.Write(outpath); // json lines file
test.CompressWrite(outpath); // compress json lines file .gz
Csv to Json Lines
var test = new ZkCsvToJsonl()
{
InputPath = @"C:\test.csv", // input file path for .csv
Encoding = Encoding.UTF8, // file encoding
HeaderF = true, // hedder -> true:exist false:not exist
Delimiter = ",", // delimita caractor
};
test.Read();
string outpath = @"C:\test.json";
test.Write(outpath); // json lines file
test.CompressWrite(outpath); // compress json lines file .gz
SQLite to Json Lines
var test = new ZkSQLiteToJsonl()
{
ConnectionString = @"Data Source=test.db",
SQLCommand = "select * From [TEST]"
};
test.Read();
string outpath = @"C:\test.json";
test.Write(outpath); // json lines file
test.CompressWrite(outpath); // compress json lines file .gz
Microsoft SQL Server to Json Lines
var test = new ZkSQLServerToJsonl()
{
ConnectionString = @"Data Source=PCNAME\SQLEXPRESS;Initial Catalog=AdventureWorks2019;User ID=testuser;Password=testuser;Encrypt=False;Trust Server Certificate=True",
SQLCommand = "select top 100 * From Person.Person"
};
test.Read();
string outpath = @"C:\test.json";
test.Write(outpath); // json lines file
test.CompressWrite(outpath); // compress json lines file .gz
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- ClosedXML (>= 0.102.2)
- CsvHelper (>= 31.0.2)
- Microsoft.Data.SqlClient (>= 5.2.0)
- Microsoft.Data.Sqlite.Core (>= 8.0.3)
- SQLitePCLRaw.bundle_e_sqlite3 (>= 2.1.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.0.15 | 229 | 6/14/2024 |
0.0.14 | 122 | 6/11/2024 |
0.0.13 | 198 | 4/10/2024 |
0.0.12 | 129 | 4/10/2024 |
0.0.11 | 127 | 4/10/2024 |
0.0.10 | 143 | 3/31/2024 |
0.0.9 | 131 | 3/31/2024 |
0.0.7 | 148 | 3/27/2024 |
0.0.6 | 134 | 3/25/2024 |
0.0.5 | 140 | 3/25/2024 |
0.0.4 | 165 | 3/24/2024 |
0.0.3 | 139 | 3/23/2024 |
0.0.2 | 140 | 3/23/2024 |
0.0.1 | 154 | 3/23/2024 |