Skip to content

Commit da48dcb

Browse files
authored
Merge pull request #19 from ws-garcia/unix+standard-escape-mechanism
Unix+standard escape mechanism
2 parents 0724ddd + 1ba4676 commit da48dcb

16 files changed

+375
-503
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
VBA CSV interface is the most complete, and open source, CSV/TSV VBA parser library nowadays. The library is RFC-4180 compliant and enables users to manipulate CSV content at the highest speed. All the modules were developed to accomplish the data exchange task with the greatest performance and to grant an easy use.
77

88
## Advantages
9-
* __Stable__. Fully Test Driven Developed (TDD) library, ([48/48 test passed](https://github.com/ws-garcia/VBA-CSV-interface/blob/master/testing/tests/results/)), that includes 500+ line of code for testing. See [VBA test library by Tim Hall](https://github.com/ws-garcia/vba-test).
9+
* __Stable__. Fully Test Driven Developed (TDD) library, ([49/49 test passed](https://github.com/ws-garcia/VBA-CSV-interface/blob/master/testing/tests/results/)), that includes 500+ line of code for testing. See [VBA test library by Tim Hall](https://github.com/ws-garcia/vba-test).
1010
* __Fast__. Writes and reads files at the highest speed.
1111
* __Memory-friendly__. CSV/[TSV](https://www.iana.org/assignments/media-types/text/tab-separated-values) files are processed using a custom stream technique, only 0.5MB are in memory at a time.
12+
* __Robust__. Parser and writer accept [Unix-style escape sequences](https://www.loc.gov/preservation/digital/formats/fdd/fdd000323.shtml#useful).
1213
* __Easy to use__. A few lines of code can do the work!
1314
* __Highly Configurable__. User can configure the parser to work with a wide range of CSV files.
1415
* __CSV data subsetting__. Split CSV data into a set of files with related data.

csv-data/assets.zip

982 KB
Binary file not shown.

docs/api/enumerations/escapetokens.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Provides a list of constants to configure the char used as escape character.
1717

1818
|**_Constant_**|**_Member name_**|
1919
|:----------|:----------|
20-
|0|*NullChar*|
2120
|1|*Apostrophe*|
2221
|2|*DoubleQuotes*|
22+
|3|*Tilde*|
2323

2424
---
2525

@@ -29,9 +29,7 @@ Provides a list of constants to configure the char used as escape character.
2929

3030
>📝**Note**
3131
>{: .text-grey-lt-000 .bg-green-000 }
32-
>The `EscapeTokens.NullChar` value is used to indicates the CSV/TSV file does not use any escape char in its whole length. This value induces the program to write the file assuming the `parserConfig.fieldsDelimiter` property is enough for the export operation.
33-
>
34-
>In the case the `parserConfig.fieldsDelimiter` property is not enough for successfully done the export operation, the `EscapeTokens.DoubleQuotes` value would be used for parse/write an CSV/TSV having fields to be escaped with double quote and the `EscapeTokens.Apostrophe` values for parse/write a file having fields to be escaped with the apostrophe.
32+
>The `EscapeTokens` enumeration is used to "escape" some CSV/TSV fields with embedded escape characters. The `parserConfig.unixEscapeMechanism` option will tell the parser to escape in the unix style, preceding the backslash (`\`), or in the classic way, preceding another escape character.
3533
{: .text-grey-dk-300 .bg-grey-lt-000 }
3634

3735
See also

docs/api/methods/exporttocsv.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Exports an array's content to a CSV/TSV file.
1515

1616
## Syntax
1717

18-
*expression*.`ExportToCSV`*(csvArray, \[pconfig:= `Nothing`\], \[PassControlToOS:= `True`\], \[enableDelimiterGuessing:= `True`\])*
18+
*expression*.`ExportToCSV`*(csvArray, \[pconfig:= `Nothing`\], \[PassControlToOS:= `True`\], \[enableDelimiterGuessing:= `True`\], \[EnforcedQuotation:= `False`\])*
1919

2020
### Parameters
2121

@@ -43,6 +43,10 @@ Exports an array's content to a CSV/TSV file.
4343
<td style="text-align: left;"><em>enableDelimiterGuessing</em></td>
4444
<td style="text-align: left;">Optional. Identifier specifying a <code>Boolean</code> Type variable.</td>
4545
</tr>
46+
<tr>
47+
<td style="text-align: left;"><em>EnforcedQuotation</em></td>
48+
<td style="text-align: left;">Optional. Identifier specifying a <code>Boolean</code> Type variable.</td>
49+
</tr>
4650
</tbody>
4751
</table>
4852

@@ -62,11 +66,11 @@ See also
6266

6367
## Behavior
6468

65-
If the `pconfig` parameter is omited, the parser will use the `ParseConfig` property as configuration object. If the file specified in the `.path` configuration property all ready exist and have some content on it the parser will try to guess delimiters and the data will be append to the file.
69+
When the `pconfig` parameter is omitted, the parser will use the `ParseConfig` property as the configuration object. If the file specified in the `.path` configuration property already exists and has some content, the parser will try to guess the delimiters and the data will be added to the file. Setting the `EnforcedQuotation` property to `True` will force to quote all fields in the created CSV file.
6670

6771
>⚠️**Caution**
6872
>{: .text-grey-lt-000 .bg-green-000 }
69-
>If there is an unescaped field, the `ExportToCSV` method will append the specified escape character to the end of the field. This is because if the data is written with this problem, the parser will not be able to import it on future occasions.
73+
>Fields containing literal escape characters will be escaped using the classic escape sequence (duplicating each escape character) or using the Unix escape sequence. The behavior will be controlled by the `unixEscapeMechanism` property of the given configuration object.
7074
{: .text-grey-dk-300 .bg-yellow-000 }
7175

7276
[Back to Methods overview](https://ws-garcia.github.io/VBA-CSV-interface/api/methods/)

docs/api/properties/parseconf.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ _Yes_
118118
<tr>
119119
<td style="text-align: left; color:blue;"><em>escapeToken</em></td>
120120
<td style="text-align: left;">Property</td>
121-
<td style="text-align: left;">Gets or sets the char that will be used for escape those fields containing some CSV/TSV syntax special char. The user must use the <code>EscapeTokens</code> enumeration to define this property.</td>
121+
<td style="text-align: left;">Gets or sets the char that will be used for quote those fields containing some CSV/TSV syntax special char. The user must use the <code>EscapeTokens</code> enumeration to define this property. The user can choose between double quotes ("), single quotes (') and tilde (~) as escapeToken.</td>
122122
</tr>
123123
<tr>
124124
<td style="text-align: left; color:blue;"><em>fieldsDelimiter</em></td>
@@ -165,6 +165,11 @@ _Yes_
165165
<td style="text-align: left;">Property</td>
166166
<td style="text-align: left;">Gets or sets the behavior of the parser when reading streams from text files. By default, this property is set to <code>False</code>. If the value is set to <code>True</code>, all line break characters in the loaded stream will be converted to <code>vbLf</code>. This option will affect performance, but may be useful when faced with CSV files with <code>vbCrLf</code>, <code>vbCr</code> and <code>vbLf</code> mixed in as line endings.</td>
167167
</tr>
168+
<tr>
169+
<td style="text-align: left; color:blue;"><em>unixEscapeMechanism</em></td>
170+
<td style="text-align: left;">Property</td>
171+
<td style="text-align: left;">Gets or sets the behavior of the parser when escaping or unescaping quotes. By default, this property is set to <code>False</code>. If the value is set to <code>True</code>, the escape character must be escaped by preceding it with a unix-style backslash (<code>\"</code>).</td>
172+
</tr>
168173
</tbody>
169174
</table>
170175

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ VBA CSV interface is the most complete, and open source, CSV/TSV VBA parser libr
1313
{: .fs-6 .fw-300 }
1414

1515
## Advantages
16-
* __Stable__. Fully Test Driven Developed (TDD) library, ([48/48 test passed](https://github.com/ws-garcia/VBA-CSV-interface/blob/master/testing/tests/results/)), that includes 500+ line of code for testing. See [VBA test library by Tim Hall](https://github.com/ws-garcia/vba-test).
16+
* __Stable__. Fully Test Driven Developed (TDD) library, ([49/49 test passed](https://github.com/ws-garcia/VBA-CSV-interface/blob/master/testing/tests/results/)), that includes 500+ line of code for testing. See [VBA test library by Tim Hall](https://github.com/ws-garcia/vba-test).
1717
* __Fast__. Writes and reads files at the highest speed.
1818
* __Memory-friendly__. CSV/[TSV](https://www.iana.org/assignments/media-types/text/tab-separated-values) files are processed using a custom stream technique, only 0.5MB are in memory at a time.
19+
* __Robust__. Parser and writer accept [Unix-style escape sequences](https://www.loc.gov/preservation/digital/formats/fdd/fdd000323.shtml#useful).
1920
* __Easy to use__. A few lines of code can do the work!
2021
* __Highly Configurable__. User can configure the parser to work with a wide range of CSV files.
2122
* __CSV data subsetting__. Split CSV data into a set of files with related data.

src/Access_version.zip

534 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)