@@ -23,7 +23,7 @@ Public Enum FieldDataType
23
23
Known = 1
24
24
UnKnown = 0
25
25
End Enum
26
- Private Function LikeCompare (ByRef value As Variant , _
26
+ Private Function LikeCompare (ByRef value As String , _
27
27
ParamArray Pattern() As Variant ) As Boolean
28
28
Dim iCounter As Long
29
29
Dim ParamLB As Long
@@ -34,7 +34,7 @@ Private Function LikeCompare(ByRef value As Variant, _
34
34
ParamUB = UBound(Pattern)
35
35
iCounter = ParamLB
36
36
Do
37
- tmpBool = value Like Pattern(iCounter)
37
+ tmpBool = value Like CStr( Pattern(iCounter) )
38
38
iCounter = iCounter + 1
39
39
Loop While iCounter <= ParamUB And Not tmpBool
40
40
LikeCompare = tmpBool
@@ -43,28 +43,30 @@ End Function
43
43
''' Attempts to detect the data type of a CSV field.
44
44
''' </summary>
45
45
''' <param name="value">CSV field content.</param>
46
- Public Function DetectDataType (ByRef value As Variant ) As FieldDataType
46
+ Public Function DetectDataType (ByRef value As String ) As FieldDataType
47
47
Dim tmpDataType As FieldDataType
48
+ Dim tmpValue As String
48
49
50
+ tmpValue = Trim(value)
49
51
tmpDataType = UnKnown
50
- If IsNumericData(value ) Then
52
+ If IsNumericData(tmpValue ) Then
51
53
tmpDataType = FieldDataType.Known
52
54
Else
53
- If IsDateOrSpecialData(value ) Then
55
+ If IsDateOrSpecialData(tmpValue ) Then
54
56
tmpDataType = FieldDataType.Known
55
57
Else
56
- If IsStructuredOrURI(value ) Then
58
+ If IsStructuredOrURI(tmpValue ) Then
57
59
tmpDataType = FieldDataType.Known
58
60
Else
59
- If IsFileSystemPath(value ) Then
61
+ If IsFileSystemPath(tmpValue ) Then
60
62
tmpDataType = FieldDataType.Known
61
63
End If
62
64
End If
63
65
End If
64
66
End If
65
67
DetectDataType = tmpDataType
66
68
End Function
67
- Private Function dmyyyyhhmmDateTime (value As Variant ) As Boolean
69
+ Private Function dmyyyyhhmmDateTime (value As String ) As Boolean
68
70
'Match DD/MM/YYYY[YYYY/DD/MM] and MM/DD/YYYY[YYYY/MM/DD] HH:MM
69
71
dmyyyyhhmmDateTime = LikeCompare(value, _
70
72
"##[-/.]##[-/.]####[T]##:##" , _
@@ -76,7 +78,7 @@ Private Function dmyyyyhhmmDateTime(value As Variant) As Boolean
76
78
"##[-/.]#[-/.]####[T]##:##" , _
77
79
"####[-/.]##[-/.]#[T]##:##" )
78
80
End Function
79
- Private Function dmyyyyhhmmssDateTime (value As Variant ) As Boolean
81
+ Private Function dmyyyyhhmmssDateTime (value As String ) As Boolean
80
82
'Match DD/MM/YYYY[YYYY/DD/MM] and MM/DD/YYYY[YYYY/MM/DD] HH:MM:SS
81
83
dmyyyyhhmmssDateTime = LikeCompare(value, _
82
84
"##[-/.]##[-/.]####[T]##:##:##" , _
@@ -88,7 +90,7 @@ Private Function dmyyyyhhmmssDateTime(value As Variant) As Boolean
88
90
"##[-/.]#[-/.]####[T]##:##:##" , _
89
91
"####[-/.]##[-/.]#[T]##:##:##" )
90
92
End Function
91
- Private Function dmyyyyhhmmssTStampedDateTime (value As Variant ) As Boolean
93
+ Private Function dmyyyyhhmmssTStampedDateTime (value As String ) As Boolean
92
94
'Match DD/MM/YYYY[YYYY/DD/MM] and MM/DD/YYYY[YYYY/MM/DD] HH:MM:SS +/- HH:MM
93
95
dmyyyyhhmmssTStampedDateTime = LikeCompare(value, _
94
96
"##[-/.]##[-/.]####[T]##:##:##[+-]##:##" , _
@@ -100,7 +102,7 @@ Private Function dmyyyyhhmmssTStampedDateTime(value As Variant) As Boolean
100
102
"##[-/.]#[-/.]####[T]##:##:##[+-]##:##" , _
101
103
"####[-/.]##[-/.]#[T]##:##:##[+-]##:##" )
102
104
End Function
103
- Private Function dmyyyyhhmmTStampedDateTime (value As Variant ) As Boolean
105
+ Private Function dmyyyyhhmmTStampedDateTime (value As String ) As Boolean
104
106
'Match DD/MM/YYYY[YYYY/DD/MM] and MM/DD/YYYY[YYYY/MM/DD] HH:MM +/- HH:MM
105
107
dmyyyyhhmmTStampedDateTime = LikeCompare(value, _
106
108
"##[-/.]##[-/.]####[T]##:##[+-]##:##" , _
@@ -112,13 +114,13 @@ Private Function dmyyyyhhmmTStampedDateTime(value As Variant) As Boolean
112
114
"##[-/.]#[-/.]####[T]##:##[+-]##:##" , _
113
115
"####[-/.]##[-/.]#[T]##:##[+-]##:##" )
114
116
End Function
115
- Private Function hhmmssTStampedDateTime (value As Variant ) As Boolean
117
+ Private Function hhmmssTStampedDateTime (value As String ) As Boolean
116
118
'Match HH:MM:SS and HH:MM +/- 00:00
117
119
hhmmssTStampedDateTime = LikeCompare(value, _
118
120
"##:##:##[+-]##:##" , _
119
121
"##:##[+-]##:##" )
120
122
End Function
121
- Private Function IsAlphaNumeric (value As Variant ) As Boolean
123
+ Private Function IsAlphaNumeric (value As String ) As Boolean
122
124
'Match ABCZ10, nullString and ABCZ_10
123
125
Dim StrLen As Long
124
126
Dim iCounter As Long
@@ -137,7 +139,7 @@ Private Function IsAlphaNumeric(value As Variant) As Boolean
137
139
Loop While iCounter <= StrLen And tmpBool
138
140
IsAlphaNumeric = tmpBool
139
141
End Function
140
- Private Function IsCurrency (value As Variant ) As Boolean
142
+ Private Function IsCurrency (value As String ) As Boolean
141
143
If LikeCompare(value, "[$€£¥]#*[.,]##" , "[$€£¥][ ]#*[.,]##" ) Then
142
144
IsCurrency = IsNumeric(Format(MidB(value, 3 ), "#,#0.00" ))
143
145
Else
@@ -146,7 +148,7 @@ Private Function IsCurrency(value As Variant) As Boolean
146
148
End If
147
149
End If
148
150
End Function
149
- Private Function IsDateOrSpecialData (value As Variant ) As Boolean
151
+ Private Function IsDateOrSpecialData (value As String ) As Boolean
150
152
Dim tmpBool As Boolean
151
153
152
154
tmpBool = IsSpecialData(value)
@@ -161,7 +163,7 @@ Private Function IsDateOrSpecialData(value As Variant) As Boolean
161
163
End If
162
164
IsDateOrSpecialData = tmpBool
163
165
End Function
164
- Private Function IsDateTime (value As Variant ) As Boolean
166
+ Private Function IsDateTime (value As String ) As Boolean
165
167
Dim tmpBool As Boolean
166
168
If InStrB(1 , value, ":" ) Then
167
169
tmpBool = hhmmssTStampedDateTime(value)
@@ -184,7 +186,7 @@ Private Function IsDateTime(value As Variant) As Boolean
184
186
End If
185
187
IsDateTime = tmpBool
186
188
End Function
187
- Private Function IsDotDate (value As Variant ) As Boolean
189
+ Private Function IsDotDate (value As String ) As Boolean
188
190
IsDotDate = LikeCompare(value, _
189
191
"####[.]##[.]##" , _
190
192
"##[.]##[.]####" , _
@@ -195,7 +197,7 @@ Private Function IsDotDate(value As Variant) As Boolean
195
197
"####[.]#[.]##" , _
196
198
"##[.]#[.]####" )
197
199
End Function
198
- Private Function IsEmail (value As Variant ) As Boolean
200
+ Private Function IsEmail (value As String ) As Boolean
199
201
If InStrB(1 , value, "@" ) Then
200
202
If value Like "*[@]*[.]?*?" Then
201
203
Dim StrLen As Long
@@ -217,7 +219,7 @@ Private Function IsEmail(value As Variant) As Boolean
217
219
End If
218
220
IsEmail = tmpBool
219
221
End Function
220
- Private Function IsFileSystemPath (value As Variant ) As Boolean
222
+ Private Function IsFileSystemPath (value As String ) As Boolean
221
223
Dim tmpBool As Boolean
222
224
223
225
If IsWindowsAbsolutePath(value) Then
@@ -229,23 +231,23 @@ Private Function IsFileSystemPath(value As Variant) As Boolean
229
231
End If
230
232
IsFileSystemPath = tmpBool
231
233
End Function
232
- Private Function IsIPv4 (value As Variant ) As Boolean
234
+ Private Function IsIPv4 (value As String ) As Boolean
233
235
If value Like "*.*.*.*" Then
234
236
IsIPv4 = IsValidIPv4(value)
235
237
End If
236
238
End Function
237
- Private Function IsISOdate (value As Variant ) As Boolean
239
+ Private Function IsISOdate (value As String ) As Boolean
238
240
'Match YYYY/MM/DDTHH:MM:SSZ and YYYY/MM/DDTHH:MM:SS[+/-]HH:MM
239
241
IsISOdate = LikeCompare(value, _
240
242
"####[-/.]##[-/.]##T##:##:##Z" , _
241
243
"####[-/.]##[-/.]##T##:##:##[+-]##:##" )
242
244
End Function
243
- Private Function IsJSfullTextDateTime (value As Variant ) As Boolean
245
+ Private Function IsJSfullTextDateTime (value As String ) As Boolean
244
246
'Match JavaScript full text date and time
245
247
IsJSfullTextDateTime = LikeCompare(value, _
246
248
"??? ??? ## #### ##:##:## *-* (*)" )
247
249
End Function
248
- Private Function IsLongOrStampedDateTime (value As Variant ) As Boolean
250
+ Private Function IsLongOrStampedDateTime (value As String ) As Boolean
249
251
Dim tmpBool As Boolean
250
252
tmpBool = IsISOdate(value)
251
253
If Not tmpBool Then
@@ -259,7 +261,7 @@ Private Function IsLongOrStampedDateTime(value As Variant) As Boolean
259
261
End If
260
262
IsLongOrStampedDateTime = tmpBool
261
263
End Function
262
- Private Function IsNumericData (value As Variant ) As Boolean
264
+ Private Function IsNumericData (value As String ) As Boolean
263
265
Dim tmpBool As Boolean
264
266
265
267
If IsNumeric(value) Then
@@ -275,7 +277,7 @@ Private Function IsNumericData(value As Variant) As Boolean
275
277
End If
276
278
IsNumericData = tmpBool
277
279
End Function
278
- Private Function IsOtherDateTime (value As Variant ) As Boolean
280
+ Private Function IsOtherDateTime (value As String ) As Boolean
279
281
Dim tmpBool As Boolean
280
282
281
283
'Match YYYY/MM/DD[ ][T]HH:MM:SS.ss and MM/DD/YYYY[ ][T]HH:MM:SS.ss
@@ -304,12 +306,12 @@ Private Function IsOtherDateTime(value As Variant) As Boolean
304
306
End If
305
307
IsOtherDateTime = tmpBool
306
308
End Function
307
- Private Function IsPercentage (value As Variant ) As Boolean
309
+ Private Function IsPercentage (value As String ) As Boolean
308
310
If LikeCompare(value, "*#[%]" ) Then
309
311
IsPercentage = IsNumeric(Format(MidB(value, 1 , LenB(value) - 2 ), "#,#0.00" ))
310
312
End If
311
313
End Function
312
- Private Function IsSpanishDate (value As Variant ) As Boolean
314
+ Private Function IsSpanishDate (value As String ) As Boolean
313
315
'Match [Lun Dic 31 01:41:00 2001 | Lun Dic 1 01:41:00 2001]
314
316
'and [Lun Dic 31 01:41:00 21 | Lun Dic 1 01:41:00 21]
315
317
IsSpanishDate = LikeCompare(value, _
@@ -318,7 +320,7 @@ Private Function IsSpanishDate(value As Variant) As Boolean
318
320
"[DLMJVS][ouai][mnreb][ ][EFMAJSOND][neabugcoi][ebrynloptvc][ ]##[ ]##:##:##[ ]##" , _
319
321
"[DLMJVS][ouai][mnreb][ ][EFMAJSOND][neabugcoi][ebrynloptvc][ ]#[ ]##:##:##[ ]##" )
320
322
End Function
321
- Private Function IsSpecialData (value As Variant ) As Boolean
323
+ Private Function IsSpecialData (value As String ) As Boolean
322
324
Dim tmpBool As Boolean
323
325
324
326
If LenB(value) = 0 Then
@@ -334,7 +336,7 @@ Private Function IsSpecialData(value As Variant) As Boolean
334
336
End If
335
337
IsSpecialData = tmpBool
336
338
End Function
337
- Private Function IsStampedDateTime (value As Variant ) As Boolean
339
+ Private Function IsStampedDateTime (value As String ) As Boolean
338
340
Dim tmpBool As Boolean
339
341
tmpBool = dmyyyyhhmmssTStampedDateTime(value)
340
342
If Not tmpBool Then
@@ -345,7 +347,7 @@ Private Function IsStampedDateTime(value As Variant) As Boolean
345
347
End If
346
348
IsStampedDateTime = tmpBool
347
349
End Function
348
- Private Function IsStructuredData (value As Variant ) As Boolean
350
+ Private Function IsStructuredData (value As String ) As Boolean
349
351
Dim tmpBool As Boolean
350
352
If InStrB(1 , value, "[" ) Then
351
353
If LikeCompare(value, "[[]*]" ) Then
@@ -373,7 +375,7 @@ Private Function IsStructuredData(value As Variant) As Boolean
373
375
End If
374
376
IsStructuredData = tmpBool
375
377
End Function
376
- Private Function IsStructuredOrURI (value As Variant ) As Boolean
378
+ Private Function IsStructuredOrURI (value As String ) As Boolean
377
379
Dim tmpBool As Boolean
378
380
379
381
If IsStructuredData(value) Then
@@ -393,10 +395,10 @@ Private Function IsStructuredOrURI(value As Variant) As Boolean
393
395
End If
394
396
IsStructuredOrURI = tmpBool
395
397
End Function
396
- Private Function IsUnixAbsolutePath (value As Variant ) As Boolean
398
+ Private Function IsUnixAbsolutePath (value As String ) As Boolean
397
399
IsUnixAbsolutePath = LikeCompare(value, "/*" )
398
400
End Function
399
- Private Function IsURL (value As Variant ) As Boolean
401
+ Private Function IsURL (value As String ) As Boolean
400
402
If InStrB(1 , value, "://" ) Then
401
403
If value Like "[a-z][a-z]*[a-z]://*" Then
402
404
If value Like "http://*" Or value Like "https://*" _
@@ -421,7 +423,7 @@ Private Function IsURL(value As Variant) As Boolean
421
423
End If
422
424
IsURL = tmpBool
423
425
End Function
424
- Private Function IsValidIPv4 (value As Variant ) As Boolean
426
+ Private Function IsValidIPv4 (value As String ) As Boolean
425
427
Dim tmpData() As String
426
428
tmpData() = Split(value, "." )
427
429
If UBound(tmpData) - LBound(tmpData) + 1 = 4 Then
@@ -447,7 +449,7 @@ Private Function IsValidIPv4(value As Variant) As Boolean
447
449
End If
448
450
End If
449
451
End Function
450
- Private Function IsValidIPv4Range (valuesArray As Variant ) As Boolean
452
+ Private Function IsValidIPv4Range (valuesArray() As String ) As Boolean
451
453
Dim iCounter As Long
452
454
Dim tmpBool As Boolean
453
455
@@ -462,7 +464,7 @@ Private Function IsValidIPv4Range(valuesArray As Variant) As Boolean
462
464
Loop While iCounter <= UBound(valuesArray) And tmpBool
463
465
IsValidIPv4Range = tmpBool
464
466
End Function
465
- Private Function IsWindowsAbsolutePath (value As Variant ) As Boolean
467
+ Private Function IsWindowsAbsolutePath (value As String ) As Boolean
466
468
IsWindowsAbsolutePath = LikeCompare(value, "[A-Za-z]:\*" )
467
469
End Function
468
470
Private Function RecordsAvgFields (ArrayList As CSVArrayList ) As Double
@@ -492,7 +494,7 @@ Private Function RecordScore(ByRef strArray As Variant) As Double
492
494
FieldsCount = 1 + UBound(strArray) - LBound(strArray)
493
495
tmpSUM = 0
494
496
For L0 = LBound(strArray) To UBound(strArray)
495
- Select Case DetectDataType(strArray(L0))
497
+ Select Case DetectDataType(CStr( strArray(L0) ))
496
498
Case FieldDataType.Known
497
499
tmpSUM = tmpSUM + 100
498
500
Case Else
@@ -544,7 +546,7 @@ Public Function TableScore(ByRef ArrayList As CSVArrayList) As Double
544
546
If ArrayList.count > 1 Then
545
547
TableScore = RecordsConsistencyFactor(ArrayList, SumRecScores) * SumRecScores / ArrayList.count
546
548
Else
547
- TableScore = RecordsConsistencyFactor(ArrayList, SumRecScores) * SumRecScores / 2
549
+ TableScore = RecordsConsistencyFactor(ArrayList, SumRecScores) * SumRecScores / 10 'Supossed number of records to be imported
548
550
End If
549
551
End If
550
552
End If
0 commit comments