Subject: | FEATURE REQUEST: Parse SEP= parameters used by Excel |
Microsoft Excel has the ability to read the field separator used in a CSV file from a "sep=" parameter specified in the first line of that file. This will ensure that the file will be properly parsed no matter the separator specified by the locale settings. (See: https://social.technet.microsoft.com/Forums/office/en-US/ee8f0432-f7d4-4730-84f3-2814eca9c06a/csv-files-arent-delimined-when-opened?forum=excel)
Unfortunately, Text::CSV_XS will read that line as a regular line in the CSV file and may alter it. (For instance, it will add quotes if "always_quote" is set to 1, which will break the functionality in Excel.
I would suggest that Text::CSV_XS function csv::in should parse that line, use it to set the "sep_char" parameter, and remove the line from the stream provided by the module. Optionally, you could pass a new argument to the "csv" function that would add it back in before writing to a file using csv::out, adjusting it's value if sep_char has been changed.