How to take only certain number lines from a list?

zmike

Client
Регистрация
24.10.2019
Сообщения
122
Благодарностей
7
Баллы
18
If my list has 80 lines.
The data are in the list named Source

Now I want to take the first 20 lines.
Do I just use List Processing > Get Line - By Number?

I tried it, but it only get the top (line number zero) line.

----

I also tried this c# code


// path to file
string path = project.Variables["pathToKeyWordFile"].Value;;
// create a list of all strings
var lines = new List<string>();
// get the number of all lines
int count = Convert.ToInt32(Macros.FileSystem.FileCountOfLines(path));
// load all lines into the list
for(int i = 0; i < count; i++)
{
lines.Add(Macros.FileSystem.FileGetLine(path, i.ToString(), false));
}
// return keywords via; in the specified range from 3 to 6
// i.e. starting from the 2nd index in the amount of 4 pieces
return string.


For pathToKeyWordFile, do I put the full file path of the text file?
Should it be folder/folder2/file.txt or folder\folder2\file.txt?
 

Вложения

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 770
Благодарностей
1 182
Баллы
113

zmike

Client
Регистрация
24.10.2019
Сообщения
122
Благодарностей
7
Баллы
18
@lokiys
Thank you so much, saved me lots of time!
 

hunthunt

Client
Регистрация
18.01.2013
Сообщения
22
Благодарностей
0
Баллы
1
{-File.GetString-|-C:\test.txt-|-0-20-|-false-}
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 770
Благодарностей
1 182
Баллы
113

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)