Skip to content

Commit fa88666

Browse files
authored
Merge pull request #16 from ws-garcia/Updates
Updates
2 parents 399a338 + 6198ac8 commit fa88666

14 files changed

+191
-54
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ VBA CSV interface is a class module developed to accomplish the data exchange ta
99
## Advantages
1010
* Writes and reads files at high speed.
1111
* Supports those CSV's that follows the RFC-4180 specs.
12-
* Supports [Tab Separated Values(TSV)](https://www.iana.org/assignments/media-types/text/tab-separated-values) files. Gracefully handles line-breaks inside TSV fields enclosed in double-quotes.
12+
* Supports [Tab Separated Values (TSV)](https://www.iana.org/assignments/media-types/text/tab-separated-values) files. Gracefully handles line-breaks inside TSV fields enclosed in double-quotes.
1313
* Auto exclude any quote mark when data is imported.
1414
* Allows an user-defined escape token (option not available in _Power Query for Excel 2019_ and with some inconsistences when user launch the _From Text(Legacy)_ wizard)[[1]](#1).
1515
* Supports One-dimensional arrays, Two-dimensional arrays and [jagged arrays](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/arrays/jagged-arrays).

docs/api/properties/commentstoken.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _Yes_
3232
|**_Accesor_**|**_Parameters_**|
3333
|:----------|:----------|
3434
|Get|_None_|
35-
|Let|*Name*: Token:<br>*Type*: `String`<br>*Modifiers*: `ByVal`|
35+
|Let|*Name*: Token<br>*Type*: `String`<br>*Modifiers*: `ByVal`|
3636

3737
|**_Accesor_**|**_Returns Type_**|
3838
|:----------|:----------|

docs/api/properties/endingrecord.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _Yes_
2929
|**_Accesor_**|**_Parameters_**|
3030
|:----------|:----------|
3131
|Get|_None_|
32-
|Let|*Name*: RecNumber:<br>*Type*: `Long`<br>*Modifiers*: `ByVal`|
32+
|Let|*Name*: RecNumber<br>*Type*: `Long`<br>*Modifiers*: `ByVal`|
3333

3434
|**_Accesor_**|**_Returns Type_**|
3535
|:----------|:----------|

docs/api/properties/escapetoken.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _Yes_
2929
|**_Accesor_**|**_Parameters_**|
3030
|:----------|:----------|
3131
|Get|_None_|
32-
|Let|*Name*: Token:<br>*Type*: `EscapeTokens`/`Long`<br>*Modifiers*: `ByVal`|
32+
|Let|*Name*: Token<br>*Type*: `EscapeTokens`/`Long`<br>*Modifiers*: `ByVal`|
3333

3434
|**_Accesor_**|**_Returns Type_**|
3535
|:----------|:----------|

docs/api/properties/fieldsdelimiter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _Yes_
2929
|**_Accesor_**|**_Parameters_**|
3030
|:----------|:----------|
3131
|Get|_None_|
32-
|Let|*Name*: Delimiter:<br>*Type*: `String`<br>*Modifiers*: `ByVal`|
32+
|Let|*Name*: Delimiter<br>*Type*: `String`<br>*Modifiers*: `ByVal`|
3333

3434
|**_Accesor_**|**_Returns Type_**|
3535
|:----------|:----------|

docs/api/properties/quotingmode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _Yes_
2929
|**_Accesor_**|**_Parameters_**|
3030
|:----------|:----------|
3131
|Get|_None_|
32-
|Let|*Name*: Mode:<br>*Type*: `QuotationMode`/`Long`<br>*Modifiers*: `ByRef`|
32+
|Let|*Name*: Mode<br>*Type*: `QuotationMode`/`Long`<br>*Modifiers*: `ByRef`|
3333

3434
|**_Accesor_**|**_Returns Type_**|
3535
|:----------|:----------|

docs/api/properties/recordsdelimiter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _Yes_
2929
|**_Accesor_**|**_Parameters_**|
3030
|:----------|:----------|
3131
|Get|_None_|
32-
|Let|*Name*: Delimiter:<br>*Type*: `String`<br>*Modifiers*: `ByVal`|
32+
|Let|*Name*: Delimiter<br>*Type*: `String`<br>*Modifiers*: `ByVal`|
3333

3434
|**_Accesor_**|**_Returns Type_**|
3535
|:----------|:----------|

docs/api/properties/startingrecord.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _Yes_
2929
|**_Accesor_**|**_Parameters_**|
3030
|:----------|:----------|
3131
|Get|_None_|
32-
|Let|*Name*: RecNumber:<br>*Type*: `Long`<br>*Modifiers*: `ByVal`|
32+
|Let|*Name*: RecNumber<br>*Type*: `Long`<br>*Modifiers*: `ByVal`|
3333

3434
|**_Accesor_**|**_Returns Type_**|
3535
|:----------|:----------|

docs/examples/exportation-examples.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ End Sub
5353
The [EXAMPLE2] shows how you can export all the data in VBA array to a CSV file without check the RFC-4180 specs rules. Be careful, use this only if the array doesn't hold especial chars (vbCrLf [vbCr, vbLf], comma [semicolon], double quotes[apostrophe]) in neither of its fields. The output CSV file has neither field needing to be escaped.
5454

5555
See also
56-
:[QuotationMode](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/quotationmode.html), [EscapeType](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/escapetype.html).
56+
:[QuotationMode](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/quotationmode.html), [EscapeTokens](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/escapetokens.html).
5757

5858
#### [EXAMPLE2]
5959
>📝**Note**
6060
>{: .text-grey-lt-000 .bg-green-000 }
61-
>the example uses the option `QuotationMode.All`, and `EscapeType.NullChar`.
61+
>the example uses the option `QuotationMode.All`, and `EscapeTokens.NullChar`.
6262
{: .text-grey-dk-300 .bg-grey-lt-000 }
6363

6464
```vb
@@ -78,21 +78,21 @@ Sub ExportToCSV()
7878
'@---------------------------------------------------------------------------------
7979
' Exportation code block start
8080
Call CSVix.OpenConnection(outputFile, DeleExistingFile:=True) 'Open a physical connection to the CSV file
81-
CSVix.QuotingMode = All 'Alter behavior for escaped files
82-
CSVix.EscapeChar = NullChar 'Specify that CSV file has neither field needing to be escaped.
81+
CSVix.QuotingMode = QuotationMode.All 'Alter behavior for escaped files
82+
CSVix.EscapeToken = EscapeTokens.NullChar 'Specify that CSV file has neither field needing to be escaped.
8383
Call CSVix.ExportToCSV (MyArray) 'Export the array content
8484
Set CSVix = Nothing 'Terminate the current instance
8585
End Sub
8686
```
8787
The [EXAMPLE3] shows how you can export all the data in VBA array to a CSV file without check the RFC-4180 specs rules. Each field CSV of the output file need to be escaped by desired char. The procedure presented in the [EXAMPLE3] can be used in whatever circumstance.
8888

8989
See also
90-
:[QuotationMode](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/quotationmode.html), [EscapeType](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/escapetype.html).
90+
:[QuotationMode](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/quotationmode.html), [EscapeTokens](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/escapetokens.html).
9191

9292
#### [EXAMPLE3]
9393
>📝**Note**
9494
>{: .text-grey-lt-000 .bg-green-000 }
95-
>the example uses the option `QuotationMode.All`, and `EscapeType.NullChar`.
95+
>the example uses the option `QuotationMode.All`, and `EscapeTokens.Apostrophe`.
9696
{: .text-grey-dk-300 .bg-grey-lt-000 }
9797

9898
```vb
@@ -112,8 +112,8 @@ Sub ExportToCSV()
112112
'@---------------------------------------------------------------------------------
113113
' Exportation code block start
114114
Call CSVix.OpenConnection(outputFile, DeleExistingFile:=True) 'Open a physical connection to the CSV file
115-
CSVix.QuotingMode = All 'Alter behavior for escaped files
116-
CSVix.EscapeChar = Apostrophe 'Each CSV’s field need to be escaped with this char.
115+
CSVix.QuotingMode = QuotationMode.All 'Alter behavior for escaped files
116+
CSVix.EscapeToken = EscapeTokens.Apostrophe 'Each CSV’s field need to be escaped with this char.
117117
Call CSVix.ExportToCSV (MyArray) 'Export the array content
118118
Set CSVix = Nothing 'Terminate the current instance
119119
End Sub

docs/examples/fileconversion.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
layout: default
3+
title: File Conversion
4+
parent: Examples
5+
nav_order: 3
6+
---
7+
8+
{: .no_toc }
9+
10+
<details open markdown="block">
11+
<summary>
12+
Table of contents
13+
</summary>
14+
{: .text-delta }
15+
1. TOC
16+
{:toc}
17+
</details>
18+
19+
>📝**Note**
20+
>{: .text-grey-lt-000 .bg-green-000 }
21+
>All the examples uses the option `QuotationMode.Critical`, [learn more here](https://ws-garcia.github.io/VBA-CSV-interface/api/enumerations/quotationmode.html).
22+
{: .text-grey-dk-300 .bg-grey-lt-000 }
23+
24+
## Convert a CSV file to TSV
25+
26+
The [EXAMPLE1] shows how you can turn a CSV file to TSV.
27+
28+
#### [EXAMPLE1]
29+
30+
```vb
31+
Sub ExportToCSV_RFC4180()
32+
Dim CSVix As CSVinterface
33+
Dim MyArray() As String
34+
Dim filePath As String, tmpCSV As String
35+
Dim outputFile As String
36+
37+
filePath = "C:\Demo_400k_records.csv" 'Change this to suit your needs
38+
outputFile = "C:\Demo_400k_records.tsv" 'Change this to suit your needs
39+
40+
Set CSVix = New CSVinterface 'Create new instance
41+
tmpCSV = CSVix.GetDataFromCSV(filePath) 'Store CSV file's content.
42+
CSVix.EndingRecord = 10 'Sets the importation ending
43+
Call CSVix.ImportFromCSVString(tmpCSV) 'Import the range of records
44+
Call CSVix(MyArray) 'Dumps the data to array
45+
'@---------------------------------------------------------------------------------
46+
' Exportation code block start
47+
CSVix.FieldsDelimiter = vbTab
48+
Call CSVix.OpenConnection(outputFile, DeleExistingFile:=True) 'Open a physical connection to the TSV file
49+
Call CSVix.ExportToCSV (MyArray) 'Export the array content
50+
Set CSVix = Nothing 'Terminate the current instance
51+
End Sub
52+
```
53+
54+
## Convert a TSV file to CSV
55+
56+
The [EXAMPLE2] shows how you can turn a TSV file to CSV.
57+
58+
#### [EXAMPLE2]
59+
60+
```vb
61+
Sub ExportToCSV_RFC4180()
62+
Dim CSVix As CSVinterface
63+
Dim MyArray() As String
64+
Dim filePath As String, tmpCSV As String
65+
Dim outputFile As String
66+
67+
filePath = "C:\Demo_400k_records.tsv" 'Change this to suit your needs
68+
outputFile = "C:\Demo_400k_records.csv" 'Change this to suit your needs
69+
70+
Set CSVix = New CSVinterface 'Create new instance
71+
tmpCSV = CSVix.GetDataFromCSV(filePath) 'Store TSV file's content.
72+
CSVix.EndingRecord = 10 'Sets the importation ending
73+
Call CSVix.ImportFromCSVString(tmpCSV) 'Import the range of records
74+
Call CSVix(MyArray) 'Dumps the data to array
75+
'@---------------------------------------------------------------------------------
76+
' Exportation code block start
77+
CSVix.FieldsDelimiter = ","
78+
Call CSVix.OpenConnection(outputFile, DeleExistingFile:=True) 'Open a physical connection to the CSV file
79+
Call CSVix.ExportToCSV (MyArray) 'Export the array content
80+
Set CSVix = Nothing 'Terminate the current instance
81+
End Sub
82+
```

0 commit comments

Comments
 (0)