-
I'm sure I'm doing something incorrectly, I'm new to steams. I'm trying to do some data filtering and write out a new file and I get white space instead of stringified json in
sample.json
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Your code fragment looks legit, but the devil is in the details. Let me annotate it with a type of stream produced by every stage of the pipeline: const pipeline = chain([
fs.createReadStream('./data/sample.json'), // TEXT
parser(), // TOKEN
pick({filter: 'DataSet.Table'}), // TOKEN
streamArray(), // OBJECT
data => // OBJECT
data.value.EmailAddress && data.value.CustomerStatus === 'Active'
? data.value
: null,
stringer(), // TEXT
fs.createWriteStream('./data/updated-sample.json')
]); Now comes the question: what kind of stream is expected by
I suspect you used the former one because the pipeline fed it with the OBJECT stream and it produced nothing. You can either switch to JSONL (just a change in the declaration) or add disssasembler() before |
Beta Was this translation helpful? Give feedback.
Your code fragment looks legit, but the devil is in the details. Let me annotate it with a type of stream produced by every stage of the pipeline:
Now comes the question: what kind of stream is expected by
stringer()
? It is a trick question because the library provides two stringers:stringer()
ofstream-json/Stringer
expe…