uCSV – CSV Parser For Unity


Assign the resulting CsvAsset to your component and call GetDocument(). ... Call the generated type’s ReadAll method to retain a list of records. ... LIMITATIONS AND IMPORTANT BEHAVIOR


by Imaginari


Price History +

uCSV

The Best Unity CSV Parser


Make the schema explicit

uCSV connects column headers to C# properties through a bundled source generator. Declare a partial record, map headers where needed and choose the generated reading API that fits how you process the data.


KEY FEATURES

• File or text input: CSV.Load and CSV.Parse return a CsvDocument; CSV.Read<T> and CSV.ReadText<T> bind compatible generated records.

• Named or indexed fields: read raw values, use Get<T>/TryGet<T>, or choose dedicated scalar TryGet accessors.

• Configurable parsing: delimiter, quote character, header handling and unquoted-field trimming; includes a tab-separated preset.

• Quoted data: handle fields containing delimiters, escaped quotes and line breaks.

• Typed conversion: strings, booleans, numeric types, enums, DateTime, Guid and nullable values. Numeric conversion uses invariant culture.

• Generated records: [CsvRecord] partial classes and structs, [CsvColumn] mappings and [CsvIgnore] exclusions.

• Generated reading APIs: ReadAll, ParseFrom, FillFrom, Enumerate and CsvColumnMap schema validation.

• Unity asset workflow: opt a .csv file into the importer to create a CsvAsset with cached document access.

• Editor browsing: custom table Inspector and a searchable, paginated CSV Preview window.


WHAT IS INCLUDED

• Runtime C# source and assembly definition.

• CSV importer override, custom Inspector and preview window source.

• Bundled Roslyn source-generator DLL with analyzer configuration; generator source is also included.

• BasicExample and SourceGeneratorExample sample folders.

• API reference, source-generator guide and runtime allocation notes.

• Runtime and Editor test sources. Inclusion of tests does not imply they were all run for this listing.


GETTING STARTED

1. Install the UPM package from disk by selecting dev.imaginari.ucsv/package.json in Package Manager.

2. Add using Imaginari.uCSV to the script that reads your data.

3. Use CSV.Load(path) for file input or CSV.Parse(rawText) for text already in memory.

4. For a Unity asset reference, select the CSV file and choose CsvScriptedImporter in its Inspector importer dropdown, then apply. Assign the resulting CsvAsset to your component and call GetDocument().

5. For generated records, mark a partial class or struct with [CsvRecord] and expose public settable properties. Call the generated type’s ReadAll method to retain a list of records.

6. To use the samples, copy the desired Samples~ folder into Assets. The current manifest does not register a Package Manager Samples UI entry.


REQUIREMENTS AND DEPENDENCIES

• Declared minimum: Unity 2021.3.0f1.

• Declared scripting requirements: .NET Standard 2.1 and C# 9.

• No package dependencies are declared in package.json.

• The runtime parser can be called from player code; Inspector and preview tools are Editor-only.

• The source-generator DLL is bundled for compiler use. Customers do not need to rebuild it or install the .NET SDK just to use the package.

• File-path APIs use System.IO.File.ReadAllText. Supply a readable path for your target; use text input when the data is already loaded through another system.


LIMITATIONS AND IMPORTANT BEHAVIOR

• CSV comments are not supported. A leading # is ordinary field content.

• The current BasicExample CSV starts with a descriptive # line. Remove that line before header-based sample usage. The artwork omits it and displays the following real headers and values.

• Match record properties and [CsvColumn] names to the data’s actual headers. The source-generator sample expects country_code, whereas the basic leaderboard uses Country; provide matching data for each example.

• Class-based Enumerate reuses one current record object. Consume its values immediately; use ReadAll when you need to retain separate records.

• CSV.Read<T>/ReadText<T> convenience dispatch uses cached reflection to find generated ReadAll. Direct generated APIs are also available.

• Parsing and List<T> creation allocate; the package is not advertised as globally allocation-free.

• Unity minimum-version behavior, IL2CPP and platform builds have not been verified in this review session.