Skip to content

Latest commit

 

History

History
102 lines (64 loc) · 2.97 KB

README.md

File metadata and controls

102 lines (64 loc) · 2.97 KB

CSV Parser for C#

Test

CSV Parser with CC0 License.

Best for:

  • Unity projects that requires cross-platform CSV parser. (maybe works on any platform supported by Unity)
  • Commercial products that you could not display the license.

Prerequisites

Environment Prerequisites
Unity 2019.2 or later None
Unity 2019.1 or earlier .NET 4.x Equivalent
.NET Project System.Memory from NuGet

Download

Download zip or unitypackage from Releases.

Usage

Methods

This returns CSV data as List<List<string>>.

CSVParser.LoadFromString(string data)  

or

CSVParser.LoadFromPath(string path, Encoding encoding = null)

Examples

var sheet = CSVParser.LoadFromString(csvString);

var styled = new StringBuilder();
foreach (var row in sheet)
{
    styled.Append("| ");

    foreach (var cell in row)
    {
        styled.Append(cell);
        styled.Append(" | ");
    }

    styled.AppendLine();
}

Debug.Log(styled.ToString());         // Unity
Console.WriteLine(styled.ToString()); // C# 

Specs

Compliant with RFC 4180.

  • Correctly parse new lines, commas, quotation marks inside cell.
  • Escaped double quotes.
  • Some encoding types. (default UTF-8)

Beta

  • Tab delimiter support

  • Async loading

Development

The repository contains multiple types of newline code. Run git config core.autocrlf false in your local repository.

Why this repo has multiple Unity Examples?

One of the reasons is to check operation in different Unity versions. Another one is to build .unitypackage with CI.

Unity changes a lot between their Tech Streams. It leads different requisites / dependency to the parser. Affected changes below.

Versions Difference
2019.1 and 2019.2 Has Scripting Runtime Version selector or not.
2021.1 and 2021.2 Requires additional DLLs or not.

License

Unique part of the repository

CC0 or Public Domain

.NET Runtimes (included in the .unitypackage for old Unity)

The MIT License

Copyright (c) .NET Foundation and Contributors