Bulk-import answer sets into a Survey form from a CSV file. Use cases: pre-populate surveys from a third-party system, migrate legacy data, bulk-edit in Excel then upload, seed test data.
Form — columns match the element naming convention (txt_1, rdb_2, chk_3, …)row:col) for matrix questionsImportReturn — count of successes, structured per-row errors, parsed List<ElementValue> ready to bind to the runtime componentPSC.Survey.Shared.Imports.CSV) targeting netstandard2.1 (usable from any .NET 6+ project, not just Blazor)SurveyBlazorUI — /importCSV — template download, upload, validation summary, and preview of imported valuesLICENCE.md (one developer, annual commercial licence, unlimited end users, no redistribution)dotnet add package PSC.Survey.Shared.Imports.CSV
using PSC.Survey.Shared.Imports.CSV;
var importer = new CSVImport { Delimiter = "|", ContinueOnError = true };
var result = importer.ImportData(csvText, form);
foreach (var row in result.Rows)
if (row.Success)
SaveAnswers(row.Values);
else
LogError(row.RowIndex, row.Errors);
And the template generator:
string template = CSVGenerator.GetColumnsTemplate(form);
// => e.g. "txt_1|txt_2|rdb_3|chk_4|…"
PSC.Survey.Shared (models) — included as a NuGet dependency.xlsx instead of text