|
| 1 | +# How to use csv-to-custom-json-python options |
| 2 | + |
| 3 | +## Options |
| 4 | + |
| 5 | +To use options, you need to add a third parameters which is an object with options. |
| 6 | + |
| 7 | +Example : |
| 8 | + |
| 9 | +```python |
| 10 | +parsedFile = parseFile("myfile.csv", schema, { |
| 11 | + debug: True |
| 12 | +}) |
| 13 | +``` |
| 14 | + |
| 15 | +## Informations for tests |
| 16 | + |
| 17 | +- For options, when it is written `boolean`, in reality, it can be any `True` value of python. Same for `False`. |
| 18 | + |
| 19 | +- command to run test |
| 20 | + |
| 21 | +```sh |
| 22 | +python3 -m unittest |
| 23 | +``` |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +### Debug |
| 28 | + |
| 29 | +> - name: `debug` |
| 30 | +> - default: `False` |
| 31 | +> - value: boolean: `True` or `False` |
| 32 | +
|
| 33 | +This options show the parsed result of your schema (can be useful sometimes) |
| 34 | + |
| 35 | +This options also allow log from the function (example, a mistake) |
| 36 | + |
| 37 | +<details> |
| 38 | +<summary>Test</summary> |
| 39 | + |
| 40 | +```sh |
| 41 | +python3 -m unittest tests/test_debug.py |
| 42 | +``` |
| 43 | + |
| 44 | +</details> |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +### Separator |
| 49 | + |
| 50 | +> - name: `separator` |
| 51 | +> - default: `,` |
| 52 | +> - values: string |
| 53 | +
|
| 54 | +`.csv` stands for "Comma Separated Values", but if you're a rebel, this options is made for you :) |
| 55 | + |
| 56 | +<details> |
| 57 | +<summary>Test</summary> |
| 58 | + |
| 59 | +```sh |
| 60 | +python3 -m unittest tests/test_custom_separator.py |
| 61 | +``` |
| 62 | + |
| 63 | +</details> |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +### Parse |
| 68 | + |
| 69 | +> - name: `parse` |
| 70 | +> - default: `True` |
| 71 | +> - value: boolean: `True` or `False` |
| 72 | +
|
| 73 | +This function deactivates the parsing of values: `function`, `int`, `float`, `string` |
| 74 | + |
| 75 | +With this function all is string |
| 76 | + |
| 77 | +<details> |
| 78 | +<summary>Test</summary> |
| 79 | + |
| 80 | +```sh |
| 81 | +python3 -m unittest tests/test_stop_parse_value.py |
| 82 | +``` |
| 83 | + |
| 84 | +</details> |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +### Line Call Back |
| 89 | + |
| 90 | +> - name: `lineCallBack` |
| 91 | +> - default: `null` |
| 92 | +> - value: function (async or not) |
| 93 | +
|
| 94 | +It activates the callBack after each line, can be useful if ou want to do a insert in database (for example) |
| 95 | + |
| 96 | +<details> |
| 97 | +<summary>Test</summary> |
| 98 | + |
| 99 | +```sh |
| 100 | +python3 -m unittest tests/test_line_callBack.py |
| 101 | +``` |
| 102 | + |
| 103 | +</details> |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +### Call Back Force |
| 108 | + |
| 109 | +> - name: `callBackForce` |
| 110 | +> - default: `False` |
| 111 | +> - value: boolean: `True` or `False` |
| 112 | +
|
| 113 | +This options allow you to force taking the result of the callBackLine even if it's `undefined` or `null` |
| 114 | + |
| 115 | +<details> |
| 116 | +<summary>Test</summary> |
| 117 | + |
| 118 | +```sh |
| 119 | +python3 -m unittest tests/test_callBack_force.py |
| 120 | +python3 -m unittest tests/test_callBack_force_2.py |
| 121 | +``` |
| 122 | + |
| 123 | +</details> |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +### Array Parse |
| 128 | + |
| 129 | +> - name: `arrayParse` |
| 130 | +> - default: `True` |
| 131 | +> - value: boolean: `True` or `False` |
| 132 | +
|
| 133 | +This options allow you to disable the parsing in an array. |
| 134 | + |
| 135 | +<details> |
| 136 | +<summary>Test</summary> |
| 137 | + |
| 138 | +```sh |
| 139 | +python3 -m unittest tests/test_array_parse.py |
| 140 | +``` |
| 141 | + |
| 142 | +</details> |
| 143 | + |
| 144 | +--- |
| 145 | + |
| 146 | +### Override First Line |
| 147 | + |
| 148 | +> - name: `overrideFirstLine` |
| 149 | +> - default: `False` |
| 150 | +> - value: `array of string` or `False` |
| 151 | +
|
| 152 | +This options allow you to override the first line. |
| 153 | + |
| 154 | +<details> |
| 155 | +<summary>Test</summary> |
| 156 | + |
| 157 | +```sh |
| 158 | +python3 -m unittest tests/test_override_first_line.py |
| 159 | +``` |
| 160 | + |
| 161 | +</details> |
| 162 | + |
| 163 | +### Private separator |
| 164 | + |
| 165 | +> - name: `privateSeparator` |
| 166 | +> - default: `...` |
| 167 | +> - value: `string` |
| 168 | +
|
| 169 | +This options allow you to change the internal separator of the script. It can be useful if values contain `.` in their names |
| 170 | + |
| 171 | +<details> |
| 172 | +<summary>Test</summary> |
| 173 | + |
| 174 | +```sh |
| 175 | +python3 -m unittest tests/test_private_separator.test.js test/private_separator_2.py |
| 176 | +``` |
| 177 | + |
| 178 | +</details> |
| 179 | + |
| 180 | +### Avoid void line |
| 181 | + |
| 182 | +> - name: `avoidVoidLine` |
| 183 | +> - default: `False` |
| 184 | +> - value: `boolean` |
| 185 | +
|
| 186 | +This options allow you to not parse void line |
| 187 | + |
| 188 | +<details> |
| 189 | +<summary>Test</summary> |
| 190 | + |
| 191 | +```sh |
| 192 | +python3 -m unittest tests/test_avoidVoidLine.test.js tests/avoidVoidLine2.test.js tests/test_avoidVoidLine3.py |
| 193 | +``` |
| 194 | + |
| 195 | +</details> |
0 commit comments