You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -62,17 +64,23 @@ We are using `fieldNames()` method and passing a list of table headers. Method `
62
64
Prettytable can load a local CSV file and print it on the console. It considers the first row to generate table headers.
63
65
64
66
```javascript
65
-
pt =require('prettytable');
67
+
PrettyTable =require('prettytable');
68
+
pt =newPrettyTable();
69
+
66
70
pt.csv("myfile.csv");
71
+
pt.print();
67
72
```
68
73
69
74
### Importing from JSON File
70
75
71
76
Like CSV, Prettytable can load a local JSON file, parse through it and finally print it on the console. Table headers are automatically determined from the keys.
72
77
73
78
```javascript
74
-
pt =require('prettytable');
79
+
PrettyTable =require('prettytable');
80
+
pt =newPrettyTable();
81
+
75
82
pt.json("myfile.json");
83
+
pt.print();
76
84
```
77
85
78
86
### Output Formats
@@ -82,7 +90,8 @@ Prettytable can print a table directly to the console, return as a string or pri
82
90
The following example shows returning the table as plain text and then printing to the console.
Prettytable also offers option to sort the table given a column name. Additional parameters can be passed to sort in ascending or descending order. If no parameter is passed, the table will be sorted in ascending order.
126
136
127
137
```javascript
128
-
pt =require('prettytable');
138
+
PrettyTable =require('prettytable');
139
+
pt =newPrettyTable();
129
140
130
141
pt.fieldNames(["name", "age", "city"]);
131
142
@@ -148,7 +159,8 @@ A single row can be deleted from the table by passing the row number to `deleteR
148
159
The following example shows all 3 of these methods.
0 commit comments