Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Allow imported csv files to have comment in them #27

Open
nh60211as opened this issue Sep 19, 2020 · 2 comments
Open

Comments

@nh60211as
Copy link

Hi,
this is a simple feature request to let imported csv files have comment mechanism
such as ignoring lines start with #.

It can be done by modifying Cirilla/ViewModels/ImportCsvWindowViewModel.cs

using (FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (TextReader tr = new StreamReader(fs, ExEncoding.UTF8))
using (CsvReader csv = new CsvReader(tr, CultureInfo.InvariantCulture))
{
csv.Configuration.HasHeaderRecord = false;
csv.Configuration.Delimiter = ";";
values = csv.GetRecords<StringKeyValuePair>().ToList();
}

to

using (FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (TextReader tr = new StreamReader(fs, ExEncoding.UTF8))
using (CsvReader csv = new CsvReader(tr))
{
	csv.Configuration.HasHeaderRecord = false;
	csv.Configuration.Delimiter = ";";
	// accept comment in csv files
	csv.Configuration.AllowComments = true;
	csv.Configuration.Comment = '#';

	values = csv.GetRecords<StringKeyValuePair>().ToList();
}

However, I found out that there doesn't seem to be a standard for csv commenting style.
So you might need to consider documenting or tell the user allowed commenting style if you were to add such feature,

Have a nice day and keep up the good work.

@Fusion86
Copy link
Owner

Looks good to me. I am currently working on a newer version, but I'll also update the current/older version on NexusMods with this change.

@nh60211as
Copy link
Author

Thanks, look forward to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants