How to count the number of lines in a file

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0
Hi guys,

Trying to detect a loop, I need to count the number of lines of my result file.

This is what Ive done:

Write a line to a result-file => bind a result-list to that result-file => get rows count of the result-list

What ever is the number of lines, get rows count returns 1.

Am I missing something? definitely....but what?

Regards
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0
WHat I've really done is that:
Write a line to a result-file => bind a result-list to that result-file => remove duplicates in the result=list => get rows count of the result-list
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
I dont know what this mess is all about :huh:
Why you do all this?
 

Thru_K

Client
Регистрация
04.07.2012
Сообщения
45
Благодарностей
12
Баллы
0
Tell me if I'm wrong rostonix, but I think when you bind a list to a file, the file is read in the start of the template and further changes in the file are not reflected in the list, unless theses changes are made via the list (with "save change list to file" enabled in the bind).

I had the same problem (with changes in a file made by external program).

One solution is to read file ('file', 'take text', put in variable1), put the result in an empty list ('word processing', variable1, 'to list', separator==enter) and finaly 'get row count' of that list.

Note that the last line break in the file (if any) is placed in the list, so you need to decrease the result by 1.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0
ok ok
My bot scraps a directory one categoy after another.

After entering a category, it scraps the whole category by clicking on a <div> style 'next-page' link at the end of the page. The bloody div.link I had to multi *.click yesterday to get the bot running.
When it reaches the last page of the category, the 'next-page' text is still present on the page, but not clickable (anti bot feature maybe? Anyway, we'll get rid of that, ahahah)
Due to the style of the link (simple <div>), I (can't | don't know how to) set up ZP to detect whether the next-page text is clickable.
So the bot enters a loop and keeps clicking on the text (not clickable) and keeps recording the last page records in the result file, again and again.

Waste of time and threads.

What I want to do is to deduplicate the result file after each page so the bot can detect when it enters a loop, because deduplicated line number won't change page after page.

Does that make sense?
Better options?
 

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0

Thru_K

Client
Регистрация
04.07.2012
Сообщения
45
Благодарностей
12
Баллы
0
rostonix, if you do that:
- bind file
- count rows (1)
- write to file (via 'file' action for exemple)
- count rows (2)

then (1) == (2)
 

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0
TABLE PROCESSING doesn't have the "remove duplicates" function :((
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
You either use file actions either list actions.
You dont need to write to file if you use construction from my template. It will be synced with file all the time.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113

Thru_K

Client
Регистрация
04.07.2012
Сообщения
45
Благодарностей
12
Баллы
0
You either use file actions either list actions.
You dont need to write to file if you use construction from my template. It will be synced with file all the time.
Yes, but in case of an external program writing on file during a run, you don't have control on that.

In this case, this work (sorry, I insist):

Read file, put the result in an empty list ('word processing', 'to list') and get row count of that list (-1 if any alone line break).

Now I stop to insist ;-)
 
  • Спасибо
Реакции: Harrythespammy

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0
I've done a little test and it appears that ZP can not bind a file in to list if changes are made to the file outside list functions.
As you mentionned it is possible to bind the list to the file once and then the work has to be done with the list to keep both sync

In my case, I need to find another condition to get out of the loop as my result file is modified outside list functions...
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
If Zennoposter use the same file while your external program rewrite it, Zenno will rewrite it back and you will loose all data written by other program.

And it will no matter how many rows it had :huh:

But if you don't mean this situation, ok :-)
 

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0

Thru_K

Client
Регистрация
04.07.2012
Сообщения
45
Благодарностей
12
Баллы
0

Harrythespammy

Новичок
Регистрация
28.02.2012
Сообщения
22
Благодарностей
0
Баллы
0
If Zennoposter use the same file while your external program rewrite it, Zenno will rewrite it back and you will loose all data written by other program.

And it will no matter how many rows it had :huh:

But if you don't mean this situation, ok :-)
Warff I wasn't talking about external program but anyway it makes me laugh ahah.

Thru_K your solution works great for me thanks
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 707
Баллы
113
Everyone smile, problem is solved :az:
 

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