How to enter data to a specific line in a file

zenno_dude

Client
Регистрация
21.01.2012
Сообщения
17
Благодарностей
0
Баллы
0
Hi people,


This is the scenario.
I'll be running multiple templates at the same time.
And the status of each template I am planning to enter into the same file.

Is there a way - I can enter a particular data from a particular template to a particular line in a file?


Thanks :-)
 

zenno_dude

Client
Регистрация
21.01.2012
Сообщения
17
Благодарностей
0
Баллы
0
I forgot to include the below info :

Example :

Template 1 should save the status in line 1 of the same file
Template 2 should save the status in line 2 of the same file
Template 3 should save the status in line 3 of the same file
Template 4 should save the status in line 4 of the same file
Template 5 should save the status in line 5 of the same file


Is there a way to do this?


Thanks
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
Did you try using list processing and setting the number ("Specify number") in it to line where you wanna ad data?

if that wont work you can always do things in old fashion way and that is using regex and replace.

How you do it?

1. Grab complete text from file.
2. If your content always starts with numbers or letters just make simple regex like: [a-zA-Z0-9].*
3. In each template you select match number
4. Use replace now (you are replacing what your regex found with what ever you would like to get there)


I hope this helps
 

zenno_dude

Client
Регистрация
21.01.2012
Сообщения
17
Благодарностей
0
Баллы
0
Hi,

Hmm, I don't think you got me right there.


Well, I am trying to write to a file - .csv file
Template 1 should write to the same file in line 1
template 2 should write to the same file in line 2

do you know how to do this?
 
Регистрация
31.07.2012
Сообщения
99
Благодарностей
14
Баллы
8
I would try the following:

1. have an action in each template - list processing, add line, write result and some info, which tells you what template it is - and make sure to set up all three checkmarks for this list, i.e. load from file, save changes and leave blank (here is screenshot, but it's in russian))
screenshot 2013-06-24 001.png

2. make sure all templates refer to this same file. This set up is good for multithreading, since you have this checkmark (save changes).

The only thing - it will NOT save result of particular template to the particular line. But, as I said, one way around it is just to have info about your template along with the result line. Hope I understood your question.
 

zenno_dude

Client
Регистрация
21.01.2012
Сообщения
17
Благодарностей
0
Баллы
0
I would try the following:

1. have an action in each template - list processing, add line, write result and some info, which tells you what template it is - and make sure to set up all three checkmarks for this list, i.e. load from file, save changes and leave blank (here is screenshot, but it's in russian))
Посмотреть вложение 4048

2. make sure all templates refer to this same file. This set up is good for multithreading, since you have this checkmark (save changes).

The only thing - it will NOT save result of particular template to the particular line. But, as I said, one way around it is just to have info about your template along with the result line. Hope I understood your question.
I don't think that will work.
If I implement what you said, yes, the result from each template will be saved in the same file.
But, after each run a new line will be there in the file.
BUT I don't want that.

My file should look like this :

Status.csv
---------------------
Template 1 : So far ran 3 times
Template 2 : So far ran 5 times
Template 3 : So far ran 4 times
------
After some time, this is how it should look

Template 1 : So far ran 8 times
Template 2 : So far ran 9 times
Template 3 : So far ran 7 times

---------

After some more time, this is how it should look

Template 1 : So far ran 54 times
Template 2 : So far ran 67 times
Template 3 : So far ran 34 times


--------


I hope now you get what I'm trying to do.
The number of lines in the file = number of templates I am running.
Also, template 1 should write only in first line
Template 2 should write only in second line
template 3 should write only in third line.
Template 4 should write only in fourth line
.
.
..
.
template x should write in xth line



This is what I'm trying to do :-)
 
Регистрация
31.07.2012
Сообщения
99
Благодарностей
14
Баллы
8
ok, let me think about it, it was not in your original question, ha-ha
meanwhile ZP gurus might pay attention to this thread =)

Edit: sorry, I quit for now, do not have a solution for you, stand by mode is on =)
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Hi,

Hmm, I don't think you got me right there.


Well, I am trying to write to a file - .csv file
Template 1 should write to the same file in line 1
template 2 should write to the same file in line 2

do you know how to do this?
DJ told you above. You would have to have some kind of identifier in your different templates so that it would know to write to a certain line. You could probably get convoluted with it and throw a bunch of C# in there to get the task ID's, but if you removed the templates from the poster the unique ID's for the templates would change. But you could have template 1 set a variable to let's say.... 0. Then when you go to change the cell value or line in csv, you would just use the variable as the line number and template 1 would save to line 0.
 
Регистрация
31.07.2012
Сообщения
99
Благодарностей
14
Баллы
8
can't find how to get info about how many times the template was finished, is it an obvious thing?
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 715
Баллы
113
You can use Write cell and change only particular data in table.
 

drvosjeca

Client
Регистрация
26.10.2011
Сообщения
512
Благодарностей
455
Баллы
63
Answer I gave is just right, I think you are the one who doesnt understand what was my suggestion... Every single issue have more possible solutions, and i served you 2 options which could work... replace is better by my oppinion, but it needs little bit more work than simple line writing, or cell writing like rostonix suggested.
 

zenno_dude

Client
Регистрация
21.01.2012
Сообщения
17
Благодарностей
0
Баллы
0
Answer I gave is just right, I think you are the one who doesnt understand what was my suggestion... Every single issue have more possible solutions, and i served you 2 options which could work... replace is better by my oppinion, but it needs little bit more work than simple line writing, or cell writing like rostonix suggested.
Hi there, could you get me your Skype ID please.
I've sent you a private message.


Thanks
 

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