stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

[RFC]: add `@stdlib/fs/read-ndjson`

Open kgryte opened this issue 2 years ago • 14 comments

Description

This RFC proposes adding a filesystem utility to read a file which is newline-delimited JSON (NDJSON).

Package: @stdlib/fs/read-ndjson Alias: readNDJSON

Related Issues

The following RFC is a prerequisite to being able to implement this feature:

  • https://github.com/stdlib-js/stdlib/issues/1075

Questions

No.

Other

For a reference package, see

Checklist

  • [X] I have read and understood the Code of Conduct.
  • [X] Searched for existing issues and pull requests.
  • [X] The issue name begins with RFC:.

kgryte avatar Aug 04 '23 15:08 kgryte

@kgryte Hey, I can take it up after #1075 gets merged. I've already made PR for #1075.

maniksharma17 avatar Feb 29 '24 11:02 maniksharma17

@maniksharma17 Yes, that seems like a natural follow-up. I'll go ahead and assign you.

kgryte avatar Mar 01 '24 11:03 kgryte

Hey @kgryte @Planeshifter , if no one is working on this issue , can I take this?

Pratik772846 avatar Mar 10 '24 19:03 Pratik772846

@Pratik772846 Hey, parse-ndjson got merged a day ago. I've started working on this one.

maniksharma17 avatar Mar 10 '24 19:03 maniksharma17

Can I work on these issue if no one is working

yaswanthkosuru avatar Sep 26 '24 02:09 yaswanthkosuru

@yaswanthkosuru , I've been working on this, i can raise a PR by the weekend. Thank you.

aayush0325 avatar Sep 26 '24 03:09 aayush0325

@yaswanthkosuru please feel free to take over this as i cannot come up with a solution as of now

aayush0325 avatar Sep 28 '24 06:09 aayush0325

@aayush0325 May I know the challenges you faced so that i will help if possible or it can help me

yaswanthkosuru avatar Sep 28 '24 06:09 yaswanthkosuru

@yaswanthkosuru I couldn't write accurate examples for this as I am not familiar with ndjson spec, tried reading about it but it really didn't work out. my index.js in examples was giving expected output when i manually ran it via Node.js but it was giving errors while i tried committing it

aayush0325 avatar Sep 28 '24 06:09 aayush0325

ok it seems like there is knowledge gap .i can take these issue .Thank u FYI:Examples look like in fs/readjson but here it can Parse \n lines also Intial Thoughts:Package look like @stdlib/fs/read-json,use parsendjson to parse

yaswanthkosuru avatar Sep 28 '24 06:09 yaswanthkosuru

yup i tried, all the best!!!

aayush0325 avatar Sep 28 '24 07:09 aayush0325

I don't think you need to support a separate *.ndjson filename extension. Just use *.json.

kgryte avatar Sep 29 '24 10:09 kgryte

@kgryte
@Planeshifter

var readNDJSON = require( '@stdlib/fs/read-ndjson' );
readNDJSON("package.json")=>returns content
readNDJSON("package.ndjson")=>returns content

is package needs to support both file formats like above? if above is the case, @stdlib/utils/parse-ndjson can only parse ndjson. Then Based on file name we can use parsejson or parsenjson to parse content. How ever i dont think it is good to go with *.json. correct me if am wrong.

yaswanthkosuru avatar Sep 29 '24 11:09 yaswanthkosuru

No, the filename extension has no bearing here. As a user, I should be able to provide a file path having any extension and the described APIs should read the file contents and attempt to parse as NDJSON. So again, we do not need to add support for a specific ndjson filename extension. The same has been true of other packages (eg, read-json, read-wasm); none of those packages care about what the filename extension is, nor should they.

kgryte avatar Sep 29 '24 18:09 kgryte