Fusion86 / Cirilla

Library + GUI to view/modify Monster Hunter World files
https://www.nexusmods.com/monsterhunterworld/mods/110
MIT License
18 stars 5 forks source link

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

Open nh60211as opened 4 years ago

nh60211as commented 4 years ago

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 https://github.com/Fusion86/Cirilla/blob/4817c0abad5923449208824dae0b151ae2794b9a/src/Cirilla/ViewModels/ImportCsvWindowViewModel.cs#L70-L78 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 commented 4 years ago

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 commented 4 years ago

Thanks, look forward to it.