I want to read identified content from a huge text file that resides in
the file system. (My javascript code is embedded in a HTML page. I am
running all code client side and have no application servers or data
base systems running.)
I've found a suggestion using 'require("fs")' but the samples required
to load the whole file content so doesn't seem to fit for my megabytes
large data file which I strictly want to avoid loading as a whole.
My data file is actually structured as <key> <TAB> <text-data> lines
and I just want to extract the <text-data> given the respective <key>.
Is there some simple standard way to achieve that extraction?
The second question is whether it is possible to find the <key>s given
a text-match (a string match or ideally a regular expression match) on
the respective <text-data> on the external file?
For a solution/workaround to both questions it might be also useful to
call an external extractor (awk, perl, ...) from javascript and read in
the output of such an external tool invocation. - Is that possible?
On 2023-04-02, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
My data file is actually structured as <key> <TAB> <text-data> lines
The second question is whether it is possible to find the <key>s given
a text-match (a string match or ideally a regular expression match) on
the respective <text-data> on the external file?
Yes? I'm not sure I understand that question.
Thanks for your hints and insights thus far!
On 02.04.2023 16:49, Jon Ribbens wrote:
On 2023-04-02, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
My data file is actually structured as <key> <TAB> <text-data> lines
The second question is whether it is possible to find the <key>s given
a text-match (a string match or ideally a regular expression match) on
the respective <text-data> on the external file?
Yes? I'm not sure I understand that question.
Where my first question was (informally described) by something like
Select <text-data> From <text-file> Where <key> Equals <search-key>
the second one operates on the data and returns text-data matching keys
that identify the data records like
Select <keys> From <text-file> Where <text-data> Matches <s1> And <s2>
with a possibility to either get all the s1/s2-matching key-identifier
in one returned set or which lets me sequentially get these keys or
let me operate on matching records (that are identified by the keys of matching records).
Basically in both questions I have want access (line-wise, record-wise)
to the data, either the <text-data> selected by <key> or the <keys>
where the <text-data> match a search criterion.
The point is; once data is read into memory accessible to JS I can do everything (including matching), but the problem is the bottleneck due
to the mass of data in the file, so I need to preselect the desired
records (to not have to load it completely into memory).
(I hope it got cleared and doesn't muddy it further.)
The suggestion of using await fetch('myfile.txt') sounds like it's
a raw (byte-oriented) data function (not line/record oriented one),
but I will be looking into that as well. Thanks again.
The suggestion of using await fetch('myfile.txt') sounds like it's
a raw (byte-oriented) data function (not line/record oriented one),
but I will be looking into that as well. Thanks again.
Janis
I want to read identified content from a huge text file that resides in
the file system. (My javascript code is embedded in a HTML page. I am running all code client side and have no application servers or data
base systems running.)
I've found a suggestion using 'require("fs")' but the samples required
to load the whole file content so doesn't seem to fit for my megabytes
large data file which I strictly want to avoid loading as a whole.
My data file is actually structured as <key> <TAB> <text-data> lines
and I just want to extract the <text-data> given the respective <key>.
Is there some simple standard way to achieve that extraction?
The second question is whether it is possible to find the <key>s given
a text-match (a string match or ideally a regular expression match) on
the respective <text-data> on the external file?
For a solution/workaround to both questions it might be also useful to
call an external extractor (awk, perl, ...) from javascript and read in
the output of such an external tool invocation. - Is that possible?
Thanks for any hints.
Janis
I want to read identified content from a huge text file that resides in
the file system. (My javascript code is embedded in a HTML page. I am running all code client side and have no application servers or data
base systems running.)
I've found a suggestion using 'require("fs")' but the samples required
to load the whole file content so doesn't seem to fit for my megabytes
large data file which I strictly want to avoid loading as a whole.
My data file is actually structured as <key> <TAB> <text-data> lines
and I just want to extract the <text-data> given the respective <key>.
Is there some simple standard way to achieve that extraction?
The second question is whether it is possible to find the <key>s given
a text-match (a string match or ideally a regular expression match) on
the respective <text-data> on the external file?
For a solution/workaround to both questions it might be also useful to
call an external extractor (awk, perl, ...) from javascript and read in
the output of such an external tool invocation. - Is that possible?
Thanks for any hints.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 251 |
Nodes: | 16 (2 / 14) |
Uptime: | 181:47:55 |
Calls: | 5,536 |
Calls today: | 2 |
Files: | 11,674 |
Messages: | 5,104,108 |