Reading Text from a text file

If you have a question or need help, this is the place to be.
allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Reading Text from a text file

Post by allalone747 » Tue Dec 22, 2015 5:55 pm

Hello everybody, I look through the forum ,for the above subject, but could not find anything,
I want to create a Calendar for 2016 in this format
Folder name Calendar for 2016 , in it there are the a sub folder for each month ,in each month there are weeks,and in weeks are days Monday - Sunday.
There will be - birthdays, - important dates, -and appointments,- and other entries. so it should look like this

Calendar- month- week- day, the days are where the editing would take place . i attach a file with text ,
My big Question is what is required for event ghost to read out the text from the text file.
Another question which follows my first question is ,if an appointment at 10:30 am, if event ghost starts up any time before 10:30 it would tell me about the appointment, but if event ghost startup after 10:30 am on the same day ,let's say 10:35 it would not tell me.
is this possible
Cheers
Attachments
Monday.txt
(260 Bytes) Downloaded 153 times

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Wed Dec 23, 2015 8:28 am

Please can I have a reply from someone
Thank you

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Mon Dec 28, 2015 2:14 pm

hello everybody,can anyone help please with my previous enquries
thank you

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Reading Text from a text file

Post by Pako » Wed Dec 30, 2015 9:09 am

Your description of the task is very difficult to understand for me.

Pako
You know flattr ? You can Image

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Wed Dec 30, 2015 1:44 pm

Pako wrote:Your description of the task is very difficult to understand for me.

Pako
Hello Pako
Thank you for replying
You are correct about not able to understand, sorry for such a bad description,i will try to be clearer
I want to create a 2016 Diary on my computer
by making a folder with 12 sub folder one for each month , in each month,will have weeks , then it will be days.
I will edit the days if i have appointments made, or if there is a birthday,( it's like a booking diary)
The question i wanted asked, how can i add action in eventghost to read out the text which is in the text file
I cannot find a plugin in eventghost to do this.
Imagine a path like this C:\2016 Diary\January\Week 1\Wednesday.txt

my second question is an expansion to the first
Let's say that on Wednesday there is an Appointment for 12:30 am,but the first startup of EventGhost was not until 13:00 PM , then EventGhost would not tell me about it because that time would have past, could that be possible.

I hope i explain it clearly this time, thank you for your help

Thank you Cheers
Attachments
Wednesday.txt
(95 Bytes) Downloaded 127 times

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Reading Text from a text file

Post by Pako » Wed Dec 30, 2015 4:15 pm

I hope i explain it clearly this time ...
No, I still do not understand your idea completely.
Your EventGhost running continuously?
If so, at what point should be done reading the file for that day?
What is the format for one item?
Time is always at the end of the sentence?
What if one day has multiple entries (that is, more of times)?
One line = one item?

Notes:
1) There is one plugin for reading text files: File Operations
2) I think there are two possible approaches to solutions:
  • A) Create SchedulGhost schedule for each text file
    B) Use a python script. It finds which text file is valid for the current day, and then performs the reading.
Pako
You know flattr ? You can Image

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Wed Dec 30, 2015 7:52 pm

Pako wrote:
I hope i explain it clearly this time ...
No, I still do not understand your idea completely.
Your EventGhost running continuously?
If so, at what point should be done reading the file for that day?
What is the format for one item?
Time is always at the end of the sentence?
What if one day has multiple entries (that is, more of times)?
One line = one item?

Notes:
1) There is one plugin for reading text files: File Operations
2) I think there are two possible approaches to solutions:
  • A) Create SchedulGhost schedule for each text file
    B) Use a python script. It finds which text file is valid for the current day, and then performs the reading.
Pako
Thank you again Pako
No EventGhost is not running continuously ,it only runs when i turn on my Computer which could be any time during the day,so it would reads the file information when the computer is switch on.

The format will be in notepad txt, or microsoft word docx
multiple entries =yes this could be possible (i did not think about this )
one line -one item yes.
FILE OPERATION
I just try File Operation, in the Read file windows i enter this
C:\2016 Diary\January\Week 1\Wednesday.txt
But i only have this return in the Log
File Operations Read Text File ; Wednesday.txt there is no sound
please can you give an example of the python script you mention in your notes B
Thanks again
cheers

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Reading Text from a text file

Post by Pako » Thu Dec 31, 2015 7:26 am

allalone747 wrote:I just try File Operation, in the Read file windows i enter this
C:\2016 Diary\January\Week 1\Wednesday.txt
But i only have this return in the Log
File Operations Read Text File ; Wednesday.txt there is no sound
Aha, I thought that the use of {eg.result} is well known.
See documentation.
SpeeakText.png
SpeeakText.png (5.62 KiB) Viewed 6765 times
The example given in the picture is simplified.
Between the two actions must be further action (Python script), where could take place parsing (evaluation time).
allalone747 wrote:The format will be in notepad txt, or microsoft word docx
It must be a plain text. Microsoft docx is a bad idea.
But my question is directed to how each item should be parsed.
It will be a unified way, where it will occur indication of the time?
allalone747 wrote:please can you give an example of the python script you mention in your notes B
I am afraid that I can not.
This is not a trivial matter. I have the Czech version of Windows and I have a different month names in the system as well as different names of days of the week.
Such a script, it will work for me, but it will not work for you.

Pako
You know flattr ? You can Image

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Thu Dec 31, 2015 7:56 pm

Thanks Pako
Between the two actions must be further action (Python script), where could take place parsing (evaluation time).
I am afraid that i have no skills with python scripts or programming so frankly i would not no where to begin

But my question is directed to how each item should be parsed.


in the day's folder i would edit the text file with each entry accommodate one line

It seems a good idea when i begin to create the Diary but as i will not be able to read text through eventghost and no one else seems to help, i thought that such a program would make starting your computer and having a reminder speaking to you, this could be add to LINKS and Jarvis speak to you, by loading up Event Ghost not only fun but a helpful tool.
To all on this great forum, May i wish you all a very happy new year 2016, all the best through the year
HAPPY NEW YEAR
Peace
Cheers
and Thank you

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Reading Text from a text file

Post by Pako » Sat Jan 02, 2016 8:41 am

Okay,
I'm thinking about it and I figured out that the script I can do.
The entire solution looks like this:
Diary.png
Diary.png (9.77 KiB) Viewed 6735 times
This is the content of the action Python script:

Code: Select all

diary_root = "C:"
code_page = eg.systemEncoding

from datetime import date as dt
from calendar import setfirstweekday, monthcalendar
from os.path import isfile
import codecs

WEEK = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
YEAR = (
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
)
today = dt.today()
day  = today.day
wd = today.isoweekday() - 1
setfirstweekday(0)
month = monthcalendar(today.year, today.month)
week = 1 + [w[wd] for w in month].index(day)
today_file = r"%s\%i Diary\%s\Week %i\%s.txt" % (diary_root, today.year, YEAR[today.month-1], week, WEEK[wd])

if not isfile(today_file):
    eg.Exit()
eg.PrintNotice("File valid for today: " + today_file)

input = codecs.open(today_file, 'r', code_page, 'ignore')
data = input.readlines()
input.close()
for line in data:
    #Here data parsing (time detection)
    eg.TriggerEvent("Speak", prefix = "Diary", payload = line)
allalone747 wrote:Another question which follows my first question is ,if an appointment at 10:30 am, if event ghost starts up any time before 10:30 it would tell me about the appointment, but if event ghost startup after 10:30 am on the same day ,let's say 10:35 it would not tell me.
This option is not yet implemented, but it can be.
The problem is that you're still did not answer the question that I was asked several times.
Then again, in greater detail:
How can I parse each item with respect to time stamp?
The timestamp will still be in the same place (for example at the end of line)?
What will be the format of the timestamp?

Pako
You know flattr ? You can Image

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Sat Jan 02, 2016 8:56 pm

Hi there Pako,
Thank you for all you time and help,i am sure other forum viewers are learning and i hope this idea will be used
It should be a good little program to give you an update of daily activity and have it spoken to you.
Cheers man

The timestamp is in GMT format
dd/MM/yyyy 02/01/2016 02 January 2016 time 2043 20:43:35 this can be seem under time zone (UTC) Dublin,Edinburgh,Lisbon,London
a sentence could be as follows Hello Sir i am reminding you of your appointment at 11:00:00 am today or sir your appointment is today timed for 11:00:00 am

Thank you Very much , just great
:)

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Sun Jan 03, 2016 1:29 pm

Hello Pako
Good day, i hope that my explanation was a bit clearer with the time format,
i didn't no if the python script should be edit to show the full path of the folder
the first line of your python script is dairy _root " c:" i enter ‪"C:\2016 Diary" this is where all the diary information are in. When i do a (Execute item) i hear Speech Speak None. i attached a copy of my XML flie. please can some one have a look see what i am going wrong thanks a lot ,

Thank you
Attachments
MY DAILY SPEECH FILE MAKEUP.xml
(2.47 KiB) Downloaded 128 times

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Reading Text from a text file

Post by Pako » Sun Jan 03, 2016 4:17 pm

allalone747 wrote:the first line of your python script is dairy_root " c:" i enter ‪"C:\2016 Diary" this is where all the diary information are in
It seems I chose the variable name dairy_root inappropriately...
If your diary is in the directory "C:\2016 Diary", then dairy_root must be "C:".
It is for this reason that it is not necessary to change the python script in 2017 and later.

Pako
You know flattr ? You can Image

allalone747
Experienced User
Posts: 81
Joined: Sun May 03, 2015 2:17 pm

Re: Reading Text from a text file

Post by allalone747 » Wed Jan 06, 2016 9:26 pm

Hi there Pako,
I send this Reply before but it may have been over looked

The timestamp is in GMT format
dd/MM/yyyy 06/01/2016 06 January 2016 time 21:19:20 this can be seem under time zone (UTC) Dublin,Edinburgh,Lisbon,London
when i enter a sentence in the text file it could read Hello Sir i am reminding you of your appointment at 11:00 am this morning so please don't be late,

Thank you
Cheers

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Reading Text from a text file

Post by Pako » Thu Jan 07, 2016 3:17 pm

allalone747 wrote:I send this Reply before but it may have been over looked
No, I have not overlooked it.
I read it.
However, I can not continue until a base (existing) solution is not working.
It still does not work? You've changed the variable dairy_root to "C:" ?

Pako
You know flattr ? You can Image

Post Reply