First 100 cells import a file

Hello!

Is there a way to only add the first 100 cells when I import a file?

I hope someone has a tip for me.

What are these cells of which you speak?
Where are you importing them to?
What file format are you working with?
What hardware and operating system are you using?

Hello!

Many thanks for your response.

I have a text file (.txt) with 2000 cells and I would like to read only the first 100.

Many thanks for the clarification!

What are these cells?
Where are you importing them to?

What hardware and operating system are you using?

Hello!

The file looks like this.

these should be in an Arry.
test.txt (10.4 KB)

Thank you for answering all my questions.

Use the file-in node to create a string of all 2000 lines.
Pass the output to a split node and then to a join node in manual to create an array
Finally a function node to truncate it using javascript code arry.length = 100.

This just uses standard nodes :wink:

[{"id":"e079c1873ece12ba","type":"file in","z":"c8c7826a005c7f46","name":"","filename":"/home/pi/.node-red/my-data/rf-log.txt","filenameType":"str","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1335,"y":375,"wires":[["e4bdc89159ced4ad"]],"l":false},{"id":"e4bdc89159ced4ad","type":"join","z":"c8c7826a005c7f46","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"10","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1420,"y":375,"wires":[["05404451237c820a"]]},{"id":"aed94a1eded0faa6","type":"inject","z":"c8c7826a005c7f46","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1245,"y":330,"wires":[["e079c1873ece12ba","c0edde3c3b50c87f"]]},{"id":"ed2d4a1cb7463eb4","type":"debug","z":"c8c7826a005c7f46","name":"debug 383","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1885,"y":375,"wires":[]},{"id":"fc0fbce825506690","type":"rbe","z":"c8c7826a005c7f46","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"block","topi":"topic","x":1730,"y":375,"wires":[["ed2d4a1cb7463eb4"]]},{"id":"05404451237c820a","type":"change","z":"c8c7826a005c7f46","name":"","rules":[{"t":"set","p":"block","pt":"msg","to":"100","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1570,"y":375,"wires":[["fc0fbce825506690"]]},{"id":"c0edde3c3b50c87f","type":"change","z":"c8c7826a005c7f46","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1570,"y":330,"wires":[["fc0fbce825506690"]]}]

Or even, using your much more sensible setting of the file-in node 1 msg per line:

The last 100 lines in the file:
image

madmax, jbudd asked you several question which you failed to respond to, it makes it difficult to help when not knowing all the info. Please in future try to respond to all questions raised, as normally they are asked for good reasons.

I am sure jbudd would of mentioned you could possibly use the head command and the exec node, but as he did not know what operating system you are using he could not tell if it would work or not.

Here is some info on the Linux head command which you could possible use in the exec node to read the first 100 lines. Head Command in Linux [5 Essential Examples]

Hello!

Thanks for the reply.

Unfortunately that is not correct. You only have to take the first 100.

If you try it doesn't always take the first 100 cells.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.