ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-users: Re: [Wireshark-users] CSV data and decimal separators

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 19 Nov 2014 20:05:11 -0800
On Nov 19, 2014, at 6:20 PM, Guy Harris <guy@xxxxxxxxxxxx> wrote:

> What do various programs do when reading comma-separated value files if:
> 
> 	1) the file contains floating-point values
> 
> and
> 
> 	2) the locale in which the program is being run uses comma, rather than period, as the decimal separator?

From a quick experiment, using Excel for Mac 2011, with a locale temporarily tweaked to use , as the decimal separator and . as the thousands separator, the wizard for importing data, if I try to import a CSV file, offers an option (under "Advanced..." in step 3 of the import wizard) to, on a per-column basis, control what characters to use as decimal and thousands separators when importing the file.  It offers , as a decimal separator and . as a thousands separator by default in that case.

With the default settings, importing a file with:

	5.3,hello,goodbye,2.18281828

results in cell A1 containing the text "5.3".  Setting cell A2 to "=A1+10" causes a value error.  Changing cell A1 to "5,3" causes cell A2 to contain "15,3".

Saving the spreadsheet as a "Windows CSV" file apparently spells "semicolon" with an initial "C", as the file was written out as a *semicolon*-separated file, with commas as decimal separators and periods as thousands separators.

Importing with . as the decimal separator and , as the thousands separator results in cell A1 containing the text "5,3", which is correctly treated as 5 and 3/10ths.