Skip to content

Commit 61320ee

Browse files
committed
CSVsubsetSplit method enhanced
1 parent b36024f commit 61320ee

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

docs/api/methods/csvsubsetsplit.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ Splits the CSV data into a set of files in which each piece has a related portio
6464

6565
The `CSVsubsetSplit` method will create a file for each different value (data grouping) in the fields at the *subsetColumns* position, then all related data is appended to the respective file. Use the *headers* parameter to include a header record in each new CSV file. The *subsetColumns* parameter can be a single value or an array of `Long` values. When the CSV file has a header record and the user sets the *header* parameter to `False`, the header row is saved in a separate file and the rest of CSV files will have no header record. The user can control when to include the headers by using the *repeatHeaders* parameter.
6666

67-
>⚠️**Caution**
68-
>{: .text-grey-lt-000 .bg-green-000 }
69-
>The user shall verify that when subdividing a CSV file using a text field/column there are no records with special characters not supported by the file system of the operating system.
70-
{: .text-grey-dk-300 .bg-yellow-000 }
71-
7267
>📝**Note**
7368
>{: .text-grey-lt-000 .bg-green-000 }
7469
>The result subsets will be saved in a folder named [\*-WorkDir], where (\*) denotes the name of the source CSV file.

src/Access_version.zip

181 Bytes
Binary file not shown.

src/All_Host_version.zip

166 Bytes
Binary file not shown.

src/CSVinterface.cls

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ Public Function CSVsubsetSplit(filePath As String, _
407407
curItems.Sort i + 1, sortingKeys:=subsetColumns
408408
RaiseEvent AfterSort
409409
tmpVar = JoinKeys(curItems, subsetColumns, i)
410-
writterConf.path = OutputPath & CStr(tmpVar) & "." & FExtension
410+
writterConf.path = ReplaceIllegalCharacters(OutputPath & CStr(tmpVar) & "." & FExtension, "_")
411411
If Headers Then
412412
'@----------------------------------------------------
413413
'Check directory
@@ -2918,6 +2918,17 @@ OutOfBounds_RemoveRecords:
29182918
Description:="The specified index is out of bounds. Please check and try again."
29192919
Resume ErrHandler_RemoveRecords
29202920
End Function
2921+
Private Function ReplaceIllegalCharacters(strIn As String, strChar As String) As String
2922+
Dim strSpecialChars As String
2923+
Dim i As Long
2924+
strSpecialChars = "~""#%&*:<>?{|}/\[]" & Chr(10) & Chr(13)
2925+
2926+
For i = 1 To Len(strSpecialChars)
2927+
strIn = Replace(strIn, Mid$(strSpecialChars, i, 1), strChar)
2928+
Next
2929+
2930+
ReplaceIllegalCharacters = strIn
2931+
End Function
29212932
Private Function RequestedField(ByVal fieldIndex As Long, _
29222933
ByVal mxReq As Long) As Boolean
29232934
Select Case RequestedFieldsArray(0)

0 commit comments

Comments
 (0)