-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcsv.node.txt
57 lines (54 loc) · 3.74 KB
/
csv.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
┏━━━━━━━━━┓
┃ CSV ┃
┗━━━━━━━━━┛
CSV #Version 0.4.1
#Manipulates:
# - CSV_STR
# - CSV_VAL (STR_ARR_ARR, OBJ_ARR or OBJ_OBJ)
#Includes following packages:
# - CSV.generate = CSV-GENERATE, creates CSV_STR
# - CSV.parse = CSV-PARSE, CSV_STR -> CSV_VAL
# - CSV.stringify = CSV-STRINGIFY, CSV_VAL -> CSV_STR
# - CSV.transform = CSV-TRANSFORM, apply FUNC on each row of CSV_VAL
CSV-GENERATE #Creates a random CSV_STR or CSV_VAL
(OBJ[, FUNC(ERROR, STR)]) #Version 0.0.4
#OBJ:
# - length NUM: rows
# - columns NUM|TYPE_STR_ARR (def: 8):
# - cols (STR_ARR is header)
# - if TYPE_STR_ARR, uses TYPE_STR_ARR.length, and generates random TYPE, not only integer.
# Can be "int" or "bool"
# - seed NUM (def: now): for random generation of STR [[:alpha:]] in each cell
# - objectMode BOOL: if false (def), returns as CSV_STR. Otherwise CSV_VAL (STR_ARR_ARR)
CSV-GENERATE(OBJ) #Same as IOSTREAM
CSV-PARSE(CSV_STR[, OBJ] #Converts .csv from single CSV_STR to CSV_VAL
[, FUNC(ERROR, CSV_VAL)]) #Version 0.0.3
#OBJ:
# - delimiter STR (def: ",", only single char)
# - rowDelimiter STR (can be single char or "unix", "mac", "windows", "auto" (def))
# - quote STR (def: '"')
# - escape STR (def: '"')
# - comment STR (def: "#")
# - skip_empty_lines BOOL (def: false)
# - [l|r]trim BOOL (def: false): around delimiter
# - auto_parse BOOL (def: false): if true, try to convert to native types, not only to strings
#CSV_VAL is either:
# - STR_ARR_ARR
# - OBJ_ARR if OBJ.columns VAL set, defining the header:
# - true: use first line
# - STR_ARR
# - FUNC(STR)->STR_ARR, where STR is first line
# - null (def, meaning STR_ARR_ARR)
# - if OBJ.objname VAR, returns OBJ_OBJ instead, where each top-level key is the header
# column VAR value for that row (so must be unique column)
CSV-PARSE([OBJ]) #Same but as IOSTREAM
CSV-STRINGIFY(CSV_VAL[, OBJ] #Inverse of CSV-PARSE (including OBJ)
[, FUNC(ERROR, CSV_STR)]) #Version 0.0.6
CSV-STRINGIFY([OBJ]) #Inverse of CSV-PARSE
CSV-TRANSFORM(CSV_VALa, #Transform a CSV_VAL by applying FUNC() or each of its row (CSV_VAL).
FUNC(VAL2a #FUNC() can return null to skip row.
[,FUNC3(ERROR, VAL2b)])->VAL2b#FUNC() can either be sync. (returning VAL2b) or async (using FUNC3)
[OBJ2][,FUNC2(EROR,CSV_VALb)])#CSV-TRANSFORM() can either be sync. or not, depending on whether FUNC2 is used.
#Version 0.0.7
#Can use OBJ2.parallel NUM: if set, do multithreading
CSV-TRANSFORM(FUNC[, OBJ]) #Same as IOSTREAM