skybrud / Skybrud.Umbraco.Redirects.Import

Import and export addon for Skybrud.Umbraco.Redirects.
MIT License
7 stars 11 forks source link

CsvRedirectsProvider: Import not separating columns at commas #5

Closed hfloyd closed 2 years ago

hfloyd commented 3 years ago

While trying to sort out the BOM issue, I realized next that the CSV file hadn't been split properly. It was only listing 1 column, even though there are two in the CSV.

This is what the debugger is showing: image

It is reading the comma as part of the first column name.

hfloyd commented 3 years ago

So, after spending an hour on these file-reading issues, I just went ahead and swapped in LinqToCsv and built a little CSV model to handle "unknown" columns. If you can figure out what was up with the loading, we can take that out, but in case you are interested, you can see the updated code in the PR.

abjerner commented 2 years ago

Hi @hfloyd

I can't remember your issue for sure, but this might be because my CsvFile class uses ; as separator by default, as it seems to be more common than actual commas (,). Different versions of Excel may even use different separator by default 🙃

Anyways, the CsvFile class now has an option where it will automatically try to determine the separator.

I found out that CSV files may also explicitly specify the used separator - eg. if the first line is sep=;, we know that the separator is ;. So the CsvFile class now also looks for this. Although my exporter current doesn't include this in the generated CSV files, it should do as - eg. because Excel understands an explicit separator declaration.

If anything else fails, the import UI also let's you select the separator.

As this should now be handled properly in the updated code, I'm closing the issue.