Skip to main content

List Operations

🔗 Original page — Source of this material


Description

❗→ Lists are mainly used for getting lines of data from a text document or file data entries. For example, you have a file with a list of URLs and you need to visit them one by one, or you're parsing some values from a site and need to sort, remove duplicates, and save them to a file (like parsed email addresses).

How do you add a list to a project?

Note

You need to create a List before getting started

image-20200807-164347

How do you add an action to a project?

Right-click and choose Add ActionListsList Operations

image-20200820-111456

Or use ❗→ Smart Search.

What is this used for?

  • Adding and retrieving list items
  • Removing lines and duplicates
  • Linking to a file
  • Getting the number of lines
  • Shuffling
  • Sorting values

How do you work with the action?

Select a sublist

Selects a specific part of the list.

image-20200807-170447

  1. Select the list you want to work with.
  2. Choose the function.
  3. Specify where the result will be saved.
  4. Sublist filter method a) ❗→ Range - set the range of lines to extract. b) Items not containing text - selects all lines not containing the given text; you can use variables. c) Items not matching ❗→ regex - search criteria using ❗→ regex. d) Items containing text - selects values containing the needed text; you can use variables. e) Items matching ❗→ regex - search criteria using ❗→ regex.
  5. Enter the value for step 4 here.
  6. Lines that match the criteria will be removed.
  7. If the ❗→ list is empty, Zennoposter will go down the red branch.
Example

Let's take the first five lines (numbering starts from zero!) from ❗→ list 1 and save them to ❗→ list 2

image-20200813-195131

❗→ List 1

Before

image-20200813-193740

After

image-20200813-194139

❗→ List 2

image-20200813-194235

Add data from list

Add data from one list to another.

image-20200807-172333

  1. Select the list you'll work with
  2. Choose the function.
  3. Specify where to take the lines from.
  4. Where to place the result - *at the end, *at the beginning, *at a position.
  5. If *at a position is chosen, enter the line number or a variable.
Note

Lines are copied, not removed from the original list.

Example

Add lines from ❗→ list 2 to the end of ❗→ list 1

image-20200813-194752

❗→ List 2

image-20200813-194658

❗→ List 1

Before

image-20200813-194906

After

image-20200813-195020

Items from list 2 remain in place

Add a line

Add a line to a list.

image-20200807-174114

  1. Select the list you'll work with
  2. Choose the function.
  3. Enter the value or variable.
  4. Where to place the result - *at the end, *at the beginning, *at a position.
  5. If you chose *at a position, enter the row number or variable.
Example

Add a value to the end of ❗→ list 1

image-20200813-195500

❗→ List 1

Before

image-20200813-195623

After

image-20200807-175124

Add text

Add text to a list.

image-20200813-201231

  1. Select the list you'll work with
  2. Choose the function.
  3. Text or character set to add to the list; you can use a variable.
  4. Where to place the result - *at the end, *at the beginning, *at a position.
  5. Add empty lines if the text is missing.
Example

Add text to ❗→ list 1

image-20200813-201439

❗→ List 1

Before

image-20200807-175812

After

image-20200813-201746

The text had a newline separator, so it was added to the list line by line

Join list items

Join list items with a separator and optionally save to a variable.

image-20200813-201948

  1. Select the list you'll work with
  2. Choose the function.
  3. Line separator a) *New line - every item will be on a new line. b) *Custom - enter your own text or characters to insert between the list items. c) *From the list settings - uses the separator from ❗→ list settings.
  4. Variable to save the processed data.
Example

Join items from ❗→ list 1, using the custom separator “-;“

image-20200807-180540

Contents of ❗→ list 1

image-20200813-202132

The result will be saved to variable *stroka

image-20200813-202258

Shuffle list items

Randomly reorder the items in a list.

image-20200807-181123

  1. Select the list you'll work with
  2. Choose the function.
Note

Changing the order will not lose any values.

Example

Shuffle the items in ❗→ list 1

image-20200813-202620

❗→ List 1

Before

image-20200813-202802

After

image-20200807-182605

Get number of lines

Get the count of lines in a list.

image-20200813-203208

  1. Select the list you'll work with
  2. Choose the function.
  3. Search criteria (can use a variable): a) All b) Do not contain text c) Do not match ❗→ regex d) With value e) Contain text f) Match ❗→ regex
  4. Variable to save result.
Note

The variable will always only contain a number.

Example

Count the number of lines in ❗→ list 1 and save it to a variable

image-20200813-203317

Contents of ❗→ list 1

image-20200807-183243

The number will be saved to variable kolichestvo_strok

image-20200813-203602

Get a line

Retrieve a line, with an option to remove it from the list and save to a variable.

image-20200807-184600

  1. Select the list you'll work with
  2. Choose the function.
  3. Line criteria (can use a variable): a) Does not contain text b) Does not match ❗→ regex c) First line d) By number e) Random f) Matches ❗→ regex
  4. Remove line after extracting
  5. Variable for saving the value.
Example

Get a random line from ❗→ list 1 into a variable

image-20200813-204726

Contents of ❗→ list 1

image-20200813-204845

The result will be saved to variable stroka

image-20200813-204934

Link a list to a file during project execution.

image-20200807-185422

  1. Select the list you'll work with
  2. Choose the function.
  3. Choose a file or specify a variable containing the file path.
  4. If a file does not exist at the path, ZennoPoster will create it automatically.
Example

Link a file to ❗→ list 1

image-20200813-205126

❗→ List 1 will be connected to the selected file

Sort

Sort list items in ascending or descending order.

image-20200813-205247

  1. Select the list you'll work with
  2. Choose the function.
  3. Use numeric principle.
  4. Choose the sort type: *descending or *ascending.
Info

Not all letter or symbol lines can be sorted

Example

Sort values in ❗→ list 1 in descending order

image-20200813-205419

❗→ List 1

Before

image-20200807-185836

After

image-20200813-205535

Save to file

image-20200813-205723

  1. Select the list you'll work with
  2. Choose the function.
  3. Choose the separator (you can use variables): a) *New line b) *Custom c) *From the list
  4. Choose the file or specify a variable containing the file path.
  5. The checkbox lets you either append to the file or overwrite it completely.
Example

Save values of ❗→ list 1 to a file

image-20200813-205753

Contents of ❗→ list 1

image-20200807-190441

After running, all values will be written to the file

image-20200813-210051

Remove duplicates

Remove duplicate lines from a list.

image-20200813-210234

  1. Select the list you'll work with
  2. Choose the function.
Note

Processing a file with a large number of lines may take some time.

Example

Remove all duplicates in ❗→ list 1

image-20200813-210423

❗→ List 1

Before

image-20200813-183938

After

1NFJfjUKn7

Remove lines

Remove lines from a list based on specific criteria.

2020-07-25_13-31-21

  1. Select the list you'll work with
  2. Choose the function.
  3. Remove lines by criteria (can use variables): a) All b) Not containing text c) Not matching ❗→ regex d) First line e) By numbers (can use ❗→ ranges) f) With value g) Containing text h) Containing only whitespace i) Matching ❗→ regex
Example

Remove lines containing character @ from ❗→ list 1

2020-08-03_20-40-14

❗→ List 1

Before

2020-08-03_20-54-19

After

2020-08-03_20-58-11

Example usage

Suppose you need to go to all pages from a list, collect their titles, and put them in another list.

2020-08-03_21-07-09

  1. Create ❗→ List_1 with the pages and link it to a file ahead of time.
  2. Remove duplicates to avoid visiting the same page twice.
  3. Create and link ❗→ List_2 to a file.
  4. Parse the required info from the pages into ❗→ List_2.
  5. Remove duplicates.

This way, you can create lists of any information you need for further processing or use.

  1. ❗→ Variables window
  2. ❗→ Regex tester
  3. ❗→ List