Skip to content

Commit 45151cb

Browse files
authored
Merge pull request #25 from ws-garcia/CSV-interfacev4.0.0
Csv interfacev4.0.0
2 parents 65dc777 + 44d94f5 commit 45151cb

File tree

89 files changed

+6782
-2525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+6782
-2525
lines changed

README.md

Lines changed: 203 additions & 141 deletions
Large diffs are not rendered by default.

csv-data/assets.zip

1.46 KB
Binary file not shown.

docs/api/csvarraylist.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: CSVArrayList
3+
parent: API
4+
nav_order: 5
5+
---
6+
7+
# CSVArrayList
8+
{: .d-inline-block }
9+
10+
New
11+
{: .label .label-purple }
12+
13+
Class module developed to emulate some functionalities from the `ArrayList` present in some most modern languages. The `CSVArrayList` serve as a container for all the data read from CSV files and can be used to manipulate the stored items, or to store data that does not come from a CSV file, according to the user's request.
14+
{: .fs-4 .fw-300 }
15+
16+
---
17+
18+
## Members
19+
20+
<table>
21+
<thead>
22+
<tr>
23+
<th style="text-align: left;">Item</th>
24+
<th style="text-align: left;">Type</th>
25+
<th style="text-align: left;">Description</th>
26+
</tr>
27+
</thead>
28+
<tbody>
29+
<tr>
30+
<td style="text-align: left; color:blue;"><em>Add</em></td>
31+
<td style="text-align: left;">Method</td>
32+
<td style="text-align: left;">Appends a copy of the specified value to the current instance. Given the nature adopted by the CSV interface to store data, if the value to be appended to the current instance is not a one-dimensional array, where each element represents a field, the user will not be able to use data sorting methods properly. User must use the <code>Add2</code> method instead if the goal is to sort stored items.</td>
33+
</tr>
34+
<tr>
35+
<td style="text-align: left; color:blue;"><em>Add2</em></td>
36+
<td style="text-align: left;">Method</td>
37+
<td style="text-align: left;">Appends a copy of the specified values to the current instance. In contrast to the <code>Add</code> method, the data is operated on before being stored, so if the values to be appended to the current instance are not one-dimensional arrays, they will be properly stored as one-dimensional array. In this way, the user will be able to use the data sorting methods provided by the class as long as no multi-dimensional arrays are stored in the current instance.</td>
38+
</tr>
39+
<tr>
40+
<td style="text-align: left; color:blue;"><em>Clear</em></td>
41+
<td style="text-align: left;">Method</td>
42+
<td style="text-align: left;">Reinitializes the current instance.</td>
43+
</tr>
44+
<tr>
45+
<td style="text-align: left; color:blue;"><em>Clone</em></td>
46+
<td style="text-align: left;">Method</td>
47+
<td style="text-align: left;">Returns a <code>CSVArraylist</code> as a exact copy of the current instance.</td>
48+
</tr>
49+
<tr>
50+
<td style="text-align: left; color:blue;"><em>Concat</em></td>
51+
<td style="text-align: left;">Method</td>
52+
<td style="text-align: left;">Concatenates the values from the current instance with the specified values and returns a <code>CSVArraylist</code> object as result. The <code>AValues</code> parameter is a <code>Variant</code> data type containing the array, <code>CSVArraylist</code> or value to concatenate.</td>
53+
</tr>
54+
<tr>
55+
<td style="text-align: left; color:blue;"><em>Copy</em></td>
56+
<td style="text-align: left;">Method</td>
57+
<td style="text-align: left;">Returns a <code>CSVArraylist</code> object with a copy of the current instance from and to a given index. The <code>StartIndex</code> parameter indicates where the copy will start and the <code>EndIndex</code> determines where the operation will end. If the <code>EndIndex</code> parameter is set to <code>-1</code>, the operation will end at the maximum index available for the current instance.</td>
58+
</tr>
59+
<tr>
60+
<td style="text-align: left; color:blue;"><em>CopyToArray</em></td>
61+
<td style="text-align: left;">Method</td>
62+
<td style="text-align: left;">Returns an array with a copy of the current instance from and to a given index. The <code>StartIndex</code> parameter indicates where the copy will start and the <code>EndIndex</code> determines where the operation will end. If the <code>EndIndex</code> parameter is set to <code>-1</code>, the operation will end at the maximum index available for the current instance.</td>
63+
</tr>
64+
<tr>
65+
<td style="text-align: left; color:blue;"><em>count</em></td>
66+
<td style="text-align: left;">Property</td>
67+
<td style="text-align: left;">Returns the amount of items stored in the current instance.</td>
68+
</tr>
69+
<tr>
70+
<td style="text-align: left; color:blue;"><em>CreateJagged</em></td>
71+
<td style="text-align: left;">Method</td>
72+
<td style="text-align: left;">Creates an empty jagged array. The operation will turns the array <code>ArrVar</code> into an jagged array with <code>ArraySize + 1</code> rows and each row with <code>VectorSize</code> columns. To access to an individual element user must use something like <code>expression(i)(j)</code>, where <code>i</code> denotes an index in the main array and <code>j</code> denotes an index in the child array.</td>
73+
</tr>
74+
<tr>
75+
<td style="text-align: left; color:blue;"><em>Insert</em></td>
76+
<td style="text-align: left;">Method</td>
77+
<td style="text-align: left;">Inserts an Item, at the given Index, in the current instance of the class.</td>
78+
</tr>
79+
<tr>
80+
<td style="text-align: left; color:blue;"><em>IsJaggedArray</em></td>
81+
<td style="text-align: left;">Method</td>
82+
<td style="text-align: left;">Returns <code>True</code> if the paseed argument is a jagged array.</td>
83+
</tr>
84+
<tr>
85+
<td style="text-align: left; color:blue;"><em>item</em></td>
86+
<td style="text-align: left;">Property</td>
87+
<td style="text-align: left;">Gets or sets an Item, by its index, from the current instance. This is the default property, so the user can use abbreviated expressions such as <code>expression(i)</code> to access the Item <code>i</code>, where <code>expression</code> represents a <code>CSVArrayList</code> object.</td>
88+
</tr>
89+
<tr>
90+
<td style="text-align: left; color:blue;"><em>items</em></td>
91+
<td style="text-align: left;">Property</td>
92+
<td style="text-align: left;">Gets or sets the collection of elements from or to the current instance. To set the elements, the <code>AValue</code> parameter must be an array.</td>
93+
</tr>
94+
<tr>
95+
<td style="text-align: left; color:blue;"><em>JaggedToTwoDimArray</em></td>
96+
<td style="text-align: left;">Method</td>
97+
<td style="text-align: left;">Turns a jagged array into a two dim array. The method will successively deconstruct and delete the jagged array, passing its contents to the specified two-dimensional array.</td>
98+
</tr>
99+
<tr>
100+
<td style="text-align: left; color:blue;"><em>MultiDimensional</em></td>
101+
<td style="text-align: left;">Method</td>
102+
<td style="text-align: left;">Checks if an array has more than one dimension and returns <code>True</code> or <code>False</code>.</td>
103+
</tr>
104+
<tr>
105+
<td style="text-align: left; color:blue;"><em>Reinitialize</em></td>
106+
<td style="text-align: left;">Method</td>
107+
<td style="text-align: left;">Reinitializes the current instance of the class and reserves the storage space desired by the user through the <code>bufferSize</code> parameter.</td>
108+
</tr>
109+
<tr>
110+
<td style="text-align: left; color:blue;"><em>RemoveAt</em></td>
111+
<td style="text-align: left;">Method</td>
112+
<td style="text-align: left;">Removes the Item at specified Index.</td>
113+
</tr>
114+
<tr>
115+
<td style="text-align: left; color:blue;"><em>RemoveRange</em></td>
116+
<td style="text-align: left;">Method</td>
117+
<td style="text-align: left;">Removes a range of Items starting at the specified Index.</td>
118+
</tr>
119+
<tr>
120+
<td style="text-align: left; color:blue;"><em>Reverse</em></td>
121+
<td style="text-align: left;">Method</td>
122+
<td style="text-align: left;">Reverse the order of the internal items, from a given <code>StartIndex</code> to a <code>EndIndex</code>.</td>
123+
</tr>
124+
<tr>
125+
<td style="text-align: left; color:blue;"><em>Reverse2</em></td>
126+
<td style="text-align: left;">Method</td>
127+
<td style="text-align: left;">Reverse the order in the target jagged array, from a given <code>StartIndex</code> to a <code>EndIndex</code>.</td>
128+
</tr>
129+
<tr>
130+
<td style="text-align: left; color:blue;"><em>ShrinkBuffer</em></td>
131+
<td style="text-align: left;">Method</td>
132+
<td style="text-align: left;">Shrinks the buffer size to avoid extra space reservation.</td>
133+
</tr>
134+
<tr>
135+
<td style="text-align: left; color:blue;"><em>Sort</em></td>
136+
<td style="text-align: left;">Method</td>
137+
<td style="text-align: left;">Sorts the internal Items. Requires all Items to be one-dimensional arrays. If the <code>FromIndex</code> is set to <code>-1</code>, the sorting will start at the Items lower bound; when the <code>ToIndex</code> is set to <code>-1</code>, the operation will end at the Items upper bound. The <code>SortingKeys</code> parameter is used to define the index of the columns on which the sorting operation will be performed, negative values indicate sorting in descending order; the user can pass an array of sorting keys as a parameter. The <code>SortAlgorithm</code> parameter indicates which sort algorithm will be used to perform the sort.</td>
138+
</tr>
139+
<tr>
140+
<td style="text-align: left; color:blue;"><em>Swap</em></td>
141+
<td style="text-align: left;">Method</td>
142+
<td style="text-align: left;">Swap Items in buffer.</td>
143+
</tr>
144+
<tr>
145+
<td style="text-align: left; color:blue;"><em>Swap2</em></td>
146+
<td style="text-align: left;">Method</td>
147+
<td style="text-align: left;">Swap Items in target jagged array.</td>
148+
</tr>
149+
<tr>
150+
<td style="text-align: left; color:blue;"><em>TwoDimToJaggedArray</em></td>
151+
<td style="text-align: left;">Method</td>
152+
<td style="text-align: left;">Turns a two-dimensional array into a jagged array. The method will successively deconstruct and delete the two-dimensional, passing its contents to the specified jagged array array.</td>
153+
</tr>
154+
</tbody>
155+
</table>
156+
157+
[Back to API overview](https://ws-garcia.github.io/VBA-CSV-interface/api/)

docs/api/csvdialect.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: CSVdialect
3+
parent: API
4+
nav_order: 6
5+
---
6+
7+
# CSVdialect
8+
{: .d-inline-block }
9+
10+
New
11+
{: .label .label-purple }
12+
13+
Class module developed to share CSV dialects, or group of specific and related configuration, which instructs the parser on how to interpret the character set read from a CSV file. This container travels through the parsing and sniffer methods.
14+
{: .fs-4 .fw-300 }
15+
16+
---
17+
18+
## Members
19+
20+
<table>
21+
<thead>
22+
<tr>
23+
<th style="text-align: left;">Item</th>
24+
<th style="text-align: left;">Type</th>
25+
<th style="text-align: left;">Description</th>
26+
</tr>
27+
</thead>
28+
<tbody>
29+
<tr>
30+
<td style="text-align: left; color:blue;"><em>escapeMode</em></td>
31+
<td style="text-align: left;">Property</td>
32+
<td style="text-align: left;">Gets or sets the escape behavior. The default value of this property is <code>EscapeStyle.rfc4180</code> and instructs the parser to escape fields according to RFC-4180 specs, if <code>EscapeStyle.unix</code> is used it will instruct the parser to escape special characters ALSO in Unix style by preceding those characters with a backslash <code>\</code>.</td>
33+
</tr>
34+
<tr>
35+
<td style="text-align: left; color:blue;"><em>fieldsDelimiter</em></td>
36+
<td style="text-align: left;">Property</td>
37+
<td style="text-align: left;">Gets or sets the character to be used to delimit the fields in the target CSV/TSV file. The default value of this property is comma <code>,</code> but the user can specify any character as field delimiter. However, it is advisable to use commonly used characters such as colon <code>:</code>, semicolon <code>;</code>, pipe <code>|</code> and tab <code>vbTab</code>.</td>
38+
</tr>
39+
<tr>
40+
<td style="text-align: left; color:blue;"><em>quoteToken</em></td>
41+
<td style="text-align: left;">Property</td>
42+
<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>QuoteTokens</code> enumeration to define this property. The user can choose between double quotes <code>"</code>, single quote <code>'</code> and tilde <code>~</code>.</td>
43+
</tr>
44+
<tr>
45+
<td style="text-align: left; color:blue;"><em>recordsDelimiter</em></td>
46+
<td style="text-align: left;">Property</td>
47+
<td style="text-align: left;">Gets or sets the char that will be used for delimit records in the target CSV/TSV file. The default value is <code>vbCrLf</code>, but user can choose one of <code>vbCr</code> and <code>vbLf</code>.</td>
48+
</tr>
49+
</tbody>
50+
</table>
51+
52+
[Back to API overview](https://ws-garcia.github.io/VBA-CSV-interface/api/)

docs/api/csvsniffer.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: CSVSniffer
3+
parent: API
4+
nav_order: 7
5+
---
6+
7+
# CSVSniffer
8+
{: .d-inline-block }
9+
10+
New
11+
{: .label .label-purple }
12+
13+
Class module developed as an attempt to sniff/guess CSV dialects without user intervention. In some preliminary tests, the sniffer was 100% accurate, but there is always the risk of facing ambiguous cases that can only be solved with human intervention. This class is inspired by the [work of scientist Till Roman Döhmen](https://homepages.cwi.nl/~boncz/msc/2016-Doehmen.pdf), with some improvements to disambiguate the most complicated cases.
14+
{: .fs-4 .fw-300 }
15+
16+
---
17+
18+
## Members
19+
20+
<table>
21+
<thead>
22+
<tr>
23+
<th style="text-align: left;">Item</th>
24+
<th style="text-align: left;">Type</th>
25+
<th style="text-align: left;">Description</th>
26+
</tr>
27+
</thead>
28+
<tbody>
29+
<tr>
30+
<td style="text-align: left; color:blue;"><em>DetectDataType</em></td>
31+
<td style="text-align: left;">Method</td>
32+
<td style="text-align: left;">Attempts to detect the data type of a CSV field. The method can detect numeric, alphanumeric, currency, date and time, email, file system paths, IP v4, percentages, urls, structured data from programming languages (bytearray, frozenset, JS arrays). The method will return <code>1</code> when it can recognize the data type present in the specified field and <code>0</code> when the field contains an unknown data type.</td>
33+
</tr>
34+
<tr>
35+
<td style="text-align: left; color:blue;"><em>TableScore</em></td>
36+
<td style="text-align: left;">Method</td>
37+
<td style="text-align: left;">Calculates a score for the CSV data based on the congruence of the detected data type and the uniformity of the fields contained in each record. The score is in the range <code>0 < x <= 100</code>. The higher the score obtained, the higher the probability that the dialect used is the correct one for the data in the analyzed CSV file. The user can pass as <code>ArrayList</code> parameter the imported data or the Items stored through the <code>Add2</code> method.</td>
38+
</tr>
39+
</tbody>
40+
</table>
41+
42+
[Back to API overview](https://ws-garcia.github.io/VBA-CSV-interface/api/)

0 commit comments

Comments
 (0)