Read LineNum in external file - Forum

Forum Navigation
You need to log in to create posts and topics.

Read LineNum in external file

Hi All,

Any one knows a good way to read specific linenum in an external text file for VisualNeo Web? The external file contain data in lines, so I just need to retrieve the data from specific line number. I tried copy/paste them into a listbox, and while it works fine (list item), it took a while to load entire 10,000 lines. Hence, it's not efficient and practical way... since I only need to retrieve specific linenum data.

the external file could be local (included during compile) or at server location.

 

Thanks, Regards

 

I tried using LoadHTML or slLoadHTML into a Container1 like

LoadHTML "Container1" "<url>/file/test.txt".  The test.txt file is actually csv text.

It loaded the file quickly in proper rows. Problem is how do I retrieve specific row(linenum)?

Any help is appreciated... thanks!

@ronnie

1) Use StrParse command to convert the loaded text (string) into an array of lines ...

StrParse "source string" "delimiter" "array variable"

... where ...

- source string is the variable associated with the Container
- delimiter will depend on whether the text file was on Windows or not ... line delimiters on Windows based files are \r\n ([#13][#10] in the days of NeoBook) ... on other systems, delimiters are just \n

2) Once you have your array variable e.g. [csvline], you can access individual lines (starting with zero) ...

[csvline(0)]
[csvline(1)]
etc.

Note that ArrayLen will give you the number of lines; so, the last line will be the value returned by ArrayLen minus 1

luishp has reacted to this post.
luishp

@gaev

Thanks. Tested it and found your suggestion works fine.  Appreciate the fast help.

Regards, Ronnie