@@ -27,23 +27,53 @@ _parquet.js requires node.js >= 14.16.0_
27
27
$ npm install @dsnp/parquetjs
28
28
```
29
29
30
- ### NodeJS
31
- To use with nodejs:
30
+ ### NodeJS
31
+ To use with nodejs:
32
32
``` javascript
33
33
import parquetjs from " @dsnp/parquetjs"
34
34
```
35
35
36
- ### Browser
37
- To use in a browser, in your bundler, depending on your needs, write the appropriate plugin or resolver to point to:
36
+ ### Browser with Bundler
37
+ To use in a browser with a bundler, depending on your needs, write the appropriate plugin or resolver to point to either the Common JS or ES Module version :
38
38
``` javascript
39
- " node_modules/@dsnp/parquetjs/browser/parquetjs"
39
+ // Common JS
40
+ " node_modules/@dsnp/parquetjs/dist/browser/parquetjs.cjs"
41
+ // ES Modules
42
+ " node_modules/@dsnp/parquetjs/dist/browser/parquetjs.esm"
40
43
```
41
44
or:
42
-
43
45
``` javascript
44
- import parquetjs from " @dsnp/parquetjs/browser/parquetjs"
46
+ // Common JS
47
+ import parquetjs from " @dsnp/parquetjs/dist/browser/parquetjs.cjs"
48
+ // ES Modules
49
+ import parquetjs from " @dsnp/parquetjs/dist/browser/parquetjs.esm"
45
50
```
46
51
52
+ ### Browser Direct: ES Modules
53
+ To use directly in the browser without a bundler using ES Modules:
54
+
55
+ 1 . Build the package: ` npm install && npm run build:browser `
56
+ 2 . Copy to ` dist/browser/parquetjs.esm.js ` the server
57
+ 3 . Use it in your html or other ES Modules:
58
+ ``` html
59
+ <script type =" module" >
60
+ import parquetjs from ' ../parquet.esm.js' ;
61
+ // Use parquetjs
62
+ </script >
63
+ ```
64
+
65
+ ### Browser Direct: Plain Ol' JavaScript
66
+ To use directly in the browser without a bundler or ES Modules:
67
+
68
+ 1. Build the package: `npm install && npm run build:browser`
69
+ 2. Copy to `dist/browser/parquetjs.js` the server
70
+ 2. Use the global `parquetjs` variable to access parquetjs functions
71
+ ```html
72
+ <script >
73
+ // console.log(parquetjs)
74
+ </script >
75
+ ```
76
+
47
77
## Usage: Writing files
48
78
49
79
Once you have installed the parquet.js library, you can import it as a single
@@ -74,7 +104,7 @@ compression.
74
104
75
105
Once we have a schema, we can create a ` ParquetWriter ` object. The writer will
76
106
take input rows as JSON objects, convert them to the Parquet format and store
77
- them on disk.
107
+ them on disk.
78
108
79
109
``` js
80
110
// create new ParquetWriter that writes to 'fruits.parquet`
@@ -88,7 +118,7 @@ await writer.appendRow({name: 'oranges', quantity: 10, price: 2.5, date: new Dat
88
118
Once we are finished adding rows to the file, we have to tell the writer object
89
119
to flush the metadata to disk and close the file by calling the ` close() ` method:
90
120
91
- ### Adding bloom filters
121
+ ### Adding bloom filters
92
122
93
123
Bloom filters can be added to multiple columns as demonstrated below:
94
124
@@ -207,7 +237,7 @@ let reader = await parquet.ParquetReader.openUrl(request,'https://domain/fruits.
207
237
### Reading data from S3
208
238
209
239
Parquet files can be read from an S3 object without having to download the whole file.
210
- You will have to supply the aws-sdk client as first argument and the bucket/key information
240
+ You will have to supply the aws-sdk client as first argument and the bucket/key information
211
241
as second argument to the function ` parquetReader.openS3 ` .
212
242
213
243
``` js
@@ -291,7 +321,7 @@ with a nested field, omit the `type` in the column definition and add a `fields`
291
321
list instead:
292
322
293
323
Consider this example, which allows us to store a more advanced "fruits" table
294
- where each row contains a name, a list of colours and a list of "stock" objects.
324
+ where each row contains a name, a list of colours and a list of "stock" objects.
295
325
296
326
``` js
297
327
// advanced fruits table
0 commit comments