Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
46 changes: 46 additions & 0 deletions .github/workflows/CI_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Continuous Integration

on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
- '*.txt'
- 'TestFiles/**'
- 'Meta/**'
- '*.log'
jobs:
build:
runs-on: windows-2022
strategy:
max-parallel: 4
matrix:
build_configuration: [Release, Debug]
build_platform: [x64, x86]

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Add msbuild to PATH
uses: microsoft/[email protected]

- name: MSBuild of solution
run: msbuild CsvQuerySolution.sln /p:configuration="${{ matrix.build_configuration }}" /p:platform="${{ matrix.build_platform }}" /m /verbosity:minimal

- name: Archive artifacts for x64
if: matrix.build_platform == 'x64' && matrix.build_configuration == 'Release'
uses: actions/upload-artifact@v3
with:
name: plugin_dll_x64
path: CsvQuery\bin\${{ matrix.build_configuration }}-x64\CsvQuery.dll

- name: Archive artifacts for x86
if: matrix.build_platform == 'x86' && matrix.build_configuration == 'Release'
uses: actions/upload-artifact@v3
with:
name: plugin_dll_x86
path: CsvQuery\bin\${{ matrix.build_configuration }}-x86\CsvQuery.dll

#- name: run tests
# run: TODO: figure out command to run for this
2 changes: 1 addition & 1 deletion CsvGen/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
2 changes: 1 addition & 1 deletion CsvGen/CsvGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>CsvGen</RootNamespace>
<AssemblyName>CsvGen</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
Expand Down
4 changes: 2 additions & 2 deletions CsvQuery/Csv/CsvSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ public IEnumerable<string[]> ParseCustom(TextReader reader)
{
var c = (char)ch;

if (c == '\n' || (c == '\r' && (char)reader.Peek() == '\n'))
if (c == '\n' || c == '\r')
{
// If it's a \r\n combo consume the \n part and throw it away.
if (c == '\r')
if (c == '\r' && ((char)reader.Peek() == '\n'))
reader.Read();

if (inQuotes)
Expand Down
2 changes: 1 addition & 1 deletion CsvQuery/CsvQuery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CsvQuery</RootNamespace>
<AssemblyName>CsvQuery</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<OutputPath>bin\$(Configuration)-$(Platform)\</OutputPath>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down
46 changes: 25 additions & 21 deletions CsvQuery/Forms/QueryWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion CsvQuery/Forms/QueryWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@ private void OnClickExecButton(object sender, EventArgs e)

private void OnQueryTextboxKeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return) this.btnExec.PerformClick();
switch (e.KeyCode)
{
case Keys.Enter: this.btnExec.PerformClick(); e.Handled = true; break;
case Keys.Tab: e.Handled = true; break;
}
}

private void OnMenuClickCreateNewCSV(object sender, EventArgs e)
Expand Down
Binary file modified Meta/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CSV Query - Notepad++ plugin
[![Build status](https://ci.appveyor.com/api/projects/status/j1r9m77jwiyfsn4u?svg=true)](https://ci.appveyor.com/project/jokedst/csvquery)

A plugin to Notepad++ to parse different types of CSV files and display them in a table.
The data is stored in a in-memory SQLite database (or MSSQL if configured), so you can write SQL queries against the data.
The data is stored in a in-memory SQLite database, so you can write SQL queries against the data.

It tries to auto-detect separators, headers and column types. If it fails it asks you for it.

Expand All @@ -13,10 +13,10 @@ It tries to auto-detect separators, headers and column types. If it fails it ask

Use modern SQL
--------------
CsvQuery has a built-in SQLite engine. This is quite old, 3.7.7.1, so new features like windowing functions doesn't work.
CsvQuery has a built-in SQLite engine. This is *quite old*, 3.7.7.1, so new features like common table expressions (`WITH` subqueries) and common table expressions don't work.
There is no plans on updating this (unless someone else makes a new C# port of SQLite).

However, CsvQuery can also use SQL Server as backend. Then all features in SQL Server can be used right from CsvQuery.
*In principle*, CsvQuery can also use SQL Server as backend. Then all features in SQL Server can be used right from CsvQuery. __*In practice, the ability of CsvQuery to connect to SQL Server has not been tested recently and is probably broken until further notice.*__

To use SQL Server you must first install SQL Server locally. Any version should work (there are free ones).
Make sure "Integrated security" is checked during install of SQL Server (it is by default).
Expand Down Expand Up @@ -52,6 +52,8 @@ CSV Query detects the separator by calculating the variance in occurrence of cha

If the first line is "significantly different" from the rest it assumes the first line is a header and use it for the column names in the database.

Prior to 2023, this plugin did not work correctly with files that had CR (Macintosh) newlines, and only worked if the line terminator was LF (Unix) or CRLF (Windows).


Used Libraries
--------------
Expand Down
18 changes: 18 additions & 0 deletions Tests/CsvColumnTypesFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ public void CanDetectNoHeader()
Assert.IsTrue(result.Columns[6].DataType == ColumnType.Decimal);
}

/// <summary>
/// With CR as the newline (rare but not unheard of),
/// the plugin should act the same as if CRLF or LF was the newline
/// </summary>
[TestMethod]
public void WorksWithCRNewline()
{
var data = CsvSettings.Comma.Parse(File.ReadAllText(@"TestFiles\random100x10 CR newline.csv")).ToList();
var result = new CsvColumnTypes(data, null);
// if there are more than 10 columns it's probably because CsvQuery didn't properly recognize CR as a newline
Assert.AreEqual(result.Columns.Count, 10);
// same tests as for previous data with header
Assert.AreEqual(true, result.HasHeader);
Assert.IsTrue(result.Columns[0].DataType == ColumnType.Integer);
Assert.IsTrue(result.Columns[7].DataType == ColumnType.Decimal);
Assert.IsTrue(result.Columns[8].DataType == ColumnType.String);
}

[TestMethod]
public void CanDetectLocalCurrency()
{
Expand Down
Loading