Here is the process we want to implement using Node streams:
- Read in a file to a stream.
- Parse a CSV file from source file stream.
- Transform the data to be hashed on one field.
- Write to a table in sqlite database.
The problem is that the hasher
transform stream is emitting/pushing the
same hash hex value each time.
I don't know the Node APIs well enough to figure out how to convert the
given chunk
into a usable string I can pass into the SHA-256 Hash
functions.
Thoughts?
To run: npm install && node streams.js
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
hash: b28c94b2195c8ed259f0b415aaee3f39b0b2920a4537611499fa044956917a21
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
{ hash: <Buffer 62 32 38 63 39 34 62 32 31 39 35 63 38 65 64 32 35 39 66 30 62 34 31 35 61 61 65 65 33 66 33 39 62 30 62 32 39 32 30 61 34 35 33 37 36 31 31 34 39 39 ... > }
Yes, I know this is an ancient version:
$ node --version
v4.4.6
$ npm version
{ 'dk-streams': '0.1.0',
npm: '2.15.5',
ares: '1.10.1-DEV',
http_parser: '2.7.0',
modules: '46',
node: '4.4.6',
openssl: '1.0.2j',
uv: '1.9.1',
v8: '4.5.103.36',
zlib: '1.2.8' }