Skip to content

Commit 64cc418

Browse files
committed
auto-update-docs
1 parent fb5d00e commit 64cc418

File tree

5 files changed

+338
-0
lines changed

5 files changed

+338
-0
lines changed

docs/Home.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Welcome to the csv-to-custom-json wiki
2+
3+
- [How to install](https://github.com/Its-Just-Nans/csv-to-custom-json/wiki/How-to-install)
4+
- [How to use](https://github.com/Its-Just-Nans/csv-to-custom-json/wiki/How-to-use)
5+
- [How to Options](https://github.com/Its-Just-Nans/csv-to-custom-json/wiki/How-to-options)
6+
- [How to CLI](https://github.com/Its-Just-Nans/csv-to-custom-json/wiki/How-to-CLI)
7+
- [How to know more](https://github.com/Its-Just-Nans/csv-to-custom-json/wiki/How-to-know-more)

docs/How-to-install.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# How to use this PyPI package ?
2+
3+
First have [Python3](https://www.python.org/) installed. If it's isn't the case, you can download it on the [official website](https://www.python.org/downloads/)
4+
5+
Then install the package with
6+
7+
```sh
8+
pip3 install csv-to-custom-json
9+
# or
10+
python3 -m pip install csv-to-custom-json
11+
```
12+
13+
> Caption :
14+
>
15+
> - `pip` stands for `Pip Installs Packages`, it can be used to download `PyPI packages`
16+
> - `csv-to-custom-json` is the name of the `PyPI packages`
17+
18+
Then if you want to use it, you can for example copy and paste this code :
19+
20+
```python
21+
from csv_to_custom_json import parseFile
22+
23+
result = parseFile("myfile.csv")
24+
25+
```
26+
27+
> Caption :
28+
>
29+
> - the name `myfile.csv` can be different, just change it with the correct name of your file
30+
31+
Now you are ready to check Options !

docs/How-to-know-more.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Tricks
2+
3+
## Array Trick
4+
5+
If you have an simple array (not with object), the function can even parse your fields
6+
7+
```python
8+
def my_func(allValues):
9+
return "hello"
10+
11+
schema = {
12+
num1: [
13+
"num4",
14+
"text",
15+
my_func,
16+
]
17+
}
18+
```
19+
20+
> Caption:
21+
>
22+
> - by default, `num4` in the firstLine will be parsed and replace by the corresponding value.
23+
> - functions are in an array and can't be identified by a name, so we can't give to it a value parameter, so the function will receive an array with all value of the current line
24+
25+
## Array schema Trick
26+
27+
Fun-fact : schema can even be an array !
28+
29+
```python
30+
def my_func(allValues):
31+
return "hello"
32+
schema = [
33+
"num4",
34+
"text",
35+
my_func
36+
]
37+
```

docs/How-to-options.md

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
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>

docs/How-to-use.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# How to use csv-to-custom-json
2+
3+
## Classic usage
4+
5+
Just import the function and use it !
6+
7+
```python
8+
from csv_to_custom_json import parseFile
9+
10+
result = parseFile("myfile.csv")
11+
```
12+
13+
## How to use the schema
14+
15+
Create a schema variable and put it as second parameter !
16+
17+
Exemple with a simple `csv` :
18+
19+
```csv
20+
num1,num2,num3
21+
1,2,3
22+
4,5,6
23+
7,8,9
24+
```
25+
26+
```python
27+
from csv_to_custom_json import parseFile
28+
29+
def callback(value):
30+
return None
31+
32+
schema = {
33+
num1: "string",
34+
callback,
35+
num3: "int"
36+
}
37+
38+
result = parseFile("myfile.csv", schema)
39+
```
40+
41+
> Caption :
42+
>
43+
> - ad you can see the schema can contains function, or string with the type
44+
> - the values with type will be parsed
45+
> - attribute of the object are the word in the first line of the csv
46+
47+
## More complexe schema
48+
49+
It's the same as a simple schema :
50+
51+
```python
52+
from csv_to_custom_json import parseFile
53+
54+
schema = {
55+
obj1: {
56+
obj2: {
57+
num4: "string"
58+
}
59+
},
60+
num2: "",
61+
num3: ""
62+
}
63+
result = parseFile("myfile.csv", schema)
64+
```
65+
66+
If you want to check some real case, check out the folder `test` in the [GitHub repository](https://github.com/Its-Just-Nans/csv-to-custom-json-python)
67+
68+
If you want to see and use options check that documentation : [How-to-options](https://github.com/Its-Just-Nans/csv-to-custom-json-python/wiki/How-to-options)

0 commit comments

Comments
 (0)