When regional settings spawn a decimal separator that is “,”, it is not possible to parse the log file. i.e.
10/20/2009 15:37:00,Kapaau, HI (Kohala MS),24,19,75,0.9,101.3,3.6, 16%,17%, 39%,39%, 60%,60%, 50%,70%, 50%,70%, 50%,70%, [FORECAST],Partly sunny with isolated showers. Haze. Highs around 82 at the 0.0 m/s to around 71 at 4000 feet. East winds around 4.5 m/s. Chance of rain 39 percent.
20/10/2009 16:00:00,Kapaau, HI (Kohala MS),24,19,75,2,7,101,2,3,6, 39%,39%, 60%,60%, 50%,50%, 50%,70%, 50%,70%, 50%,70%, [FORECAST],Partly sunny with isolated showers. Haze. Highs around 82 at the 0,0 m/s to around 71 at 4000 feet. East winds around 4,5 m/s. Chance of rain 60 percent.
These are two sequential records: one for Eng(US) and one for French(France). The “,” decimal separator is ambiguous with the field separator “,”. Perhaps, a field separator of “#” would avoid this issue when the decimal separtor is “,”. in vb.net.
Both can be accomodated if mixed with the following code:
Imports System.Globalization
.
.
.
'To accomodate both if mixed on a file, the following code is useful:
Public sep As String = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator
strRecord = LineInput(fnum)
If strRecord.IndexOf("#") > 0 Then
fieldchar = "#"
sepin = ","
Else
fieldchar = ","
sepin = "."
End If
strData = strRecord.Split(fieldchar)
Dim i As Integer
For i = 0 To strData.GetUpperBound(0)
strData(i) = strData(i).Replace(sepin, sep)
Next
In addition, the date issued can be circumvented by using the universal sortable format:
yyyy-MM-dd HH:mm:ss z
This can be processed using the following:
Dim expectedFormats As String() = {“u”}
Dim format As New System.Globalization.CultureInfo(culture, True)
dt = System.DateTime.ParseExact(strData(0), expectedFormats, format, _
System.Globalization.DateTimeStyles.AllowWhiteSpaces)
“culture” is exposed in the Globalization namespace
Just a suggestion for a future version.