Sunday, September 5, 2021

2011-Jan-25 (Communication Skills Exam)



Index of Journals
25 January 2011

I had English exam today. It didn’t go well.
I had to be awake last night but then I slept at 0400 in the morning. That was not all, I was listening to music and entertaining myself, including regular jobs, since I came back home after giving computer exam. It was 0230 last night when picked up English notes. And within one and a half hours, I was down.
I woke up at around 0730 and regular day starts.
I was sitting with Raghav Aggrawal. He is so weak in grammar and he almost did nothing by himself in those questions. The teacher had come behind me to warn right after the first time. But, Raghav wasn’t stopping. 
I missed the last question from Literature-type section. I was anyway not going to score in that.
I doubt if I would get easy marks for grammar, reading, and writing (the one which sought for explanations) section.
I was home, after having been to college, at five. And there was no food, so I went to bed in bad mood. These women at home are total bullshit.

Babaji asked me question from 'Introduction to computers' question paper which I didn’t want to answer so I just indirectly said no. And he didn’t like, and I was not caring. He doesn’t deserve a word from me. 
I re-checked question paper again if there was any hope. And yes, there is.

I just watched ‘Social Network’ again. The movie is inspiring. 

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

2011-Jan-24 (Introduction to Computers Exam)



Index of Journals
January 24, 2011

I was awaken whole night. I was in so much bad mood about myself. I was watching TV at all times last evening. I closed the TV around 2000 and then Prashant and Srishti started some award show. I came out to watch it with them. They left minutes before it was too late for oldies to come back home. And they came around 2300 with few eatables, like samosa(s) and daal-pakoda(s) for us. 
I watched the award show till late 0030. Then, I had tea and took up my ITC (Introduction to Computers) book for one last time.
I left for college after having tea and popping paracetamol. It was fine during the exam except for the fact that I had to go to loo once.

On the return trip, I was accompanied by Luv. It was on Barakhamba Metro Station that our train stopped. I was shaking my leg while standing on the door and was watching the girls de-board the train from the next women-special carriage. I didn’t notice that the man standing against the wall right in front of me on the empty platform was polio-patient. He had crutches and then I notices that his right leg was about two-three inches shorter than the left. I felt bad for myself and then I just waited for the train to shut the door and leave the station. But it took longer than usual and I had my neck down for all those minutes. 
Things will have to change one day, for good, I will change them.

Then earlier on the Yellow-line (of metro track), there was a young-girl of about my age with all the branded fashion accessories. I made Luv count her worth and it was over Rs 30000 on the go, not counting her bra and panty. 

In the morning on the Red-line (of metro track), there were these two love birds making love on the train. It was okay for me but not for that sardar who was approximately of their father’s age (may be older). The person was almost running his hands everywhere on the body of that girl, with out hesitation form either side.

The exam went fine. I am passing this one.
Now, it’s just English tomorrow.

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-23) Laptop Request



Index of Journals
January 23, 2011

Last night I was awake till 0330, listening to radio. It felt awesome to listen to those Bollywood songs, and Hindi music. I was unwell. I still am unwell. This break from college proved hard on my mental being. I need to get back there; home is not the place to where I belong. 
I was sleeping in the afternoon. I didn’t study whole day today. It is going to be hard tonight. 
Amma, babaji, chachi, and Anu are gone to the wedding. They left before me, after babaji had wished me ‘good morning’ at 1710. I didn’t know how to react to that, so I wished back.
Yesterday, he was telling if I would like to go to classes in Acharya Niketan. I told him to get me a laptop of those R20000 which he would give for classes. And, guess what he told me... An all new answer to reply to me, “You can go to badi buaji’s house and do your work there as long as you want. That computer is totally yours. Go and sit over there to work as long as you wish to.” “He has lost his mind,” I said to myself.

There is no peace here; Srishti is here to ask for remote. And there are harsh words for you to listen if you don’t do as she says.

God Bless ‘Me’
Ashish
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-22) Hindi



Index of Journals
January 22, 2011

It feels like Hindi is in its days. The last people who speak this language only are seeing there third generation today. It feels bad to see them in a pitiful situation. A language is what gives shape to a culture. The language changes, the people change. If languages are wiped out form the face of the Earth it will by itself remove many religious-extremists. That's, of course, because not many religions have religious texts in English. So, changing your tongue means a lot more than just changing your medium of communication. 
Hindi is dying out, and I am one of the killers, unfortunate. Sometimes I feel very bad for “why it is me who is in this situation, and not those English speakers, why my thinking was molded by events to take myself up so harshly to quit Hindi and take up English?” 
Now I can’t do anything than just feeling bad for morally killing myself.

I was going in my own way to study and sleep through the day. It was in the evening, during the dinner time. This news was coming which showed this mixing up of Hindi with all other languages and losing its original form.
It makes me feel bad when I see amma getting irritated by me watching English movies. First, she can’t understand this foreign language, and then the language which she speaks is losing its shine.

Buaji and I have been stealing eyes; don’t know what the new drama is. But because I don’t know why it is so, nor I can see any logic myself, so I am not digging into this matter.

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-21) Money Issues



Index of Journals
January 21, 2011

I just started the day like another regular one. I took the books around one in the afternoon and then I thought to get an AutoCAD book from library. So after begging for little money from amma for a quite awhile, I got Rs 10 from her and I had to spend from my own pocket. I had to ask Anu also but it wasn’t surprising to hear her say no. What now looks surprising to me is that I actually expected help from that dumbass, bloody idiot!
When I was asking amma for money and I had her purse Prachi came over to make me give amma purse back. And she had that strange look on her face which I have never seen before, that was very strange. Stern, confident, stiff, I just wondered who this person is.

I went to college and got the book. It felt comfortable to not find that woman-librarian there. She is pretty but such a b***h. She looks troubled because of me going there to issue book. Prateek of second section was sitting there. I just talked to him for a while and then I came back home. I was walking behind HOD and then he turned back to see me coming but why did he steel away eyes quickly.

It was really a bad experience to get re-acquainted with Shastri Park, polluted air, dingy roads, and poverty-stricken masses. 
“Enough shit to make a lively person leave interest in living.”

After coming back home, I was sleeping and then was on TV till seven. You know, amma can do without telling me to get up, because I will anyway have to get up some time. But after she says it, I just can’t feel like showing respect to her. She doesn’t deserve it.

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-20) Prashant's birthday



Index of Journals
January 20, 2011

Okay, the day started normally late. I got up around ten and started the day off with heavy breakfast. I took the English notes back to catch up with it. Computer Science can wait. Two exams in succession to each other, five days preparatory leave left me puzzled what to take up and what to put for tomorrow? I started with English and am still on that. Now, it is time get worried because I have been running slowly and time left is less for the course that’s left. Huh!

I almost forgot Prashant’s birthday, it occurred to me when amma wished him in the morning. Nothing, it didn’t become crowded again. Manju buaji was here to pick up children and she left after wishing Prashant. I was sleeping in the afternoon till evening six-forty when I heard badi buaji in the dining room. I went out after taking my time in seeing to it that kids hadn’t come. Who wants useless talk?
She left by seven. I was watching television till eight-thirty. Chachiji had held everybody to wait till Prashant and Srishti were reaching home. I was silly for having wasted time in watching TV during this time. Okay, so Dominos pizzas were ordered, Pav-bhaji included.

I had wished Prashant in the evening while watching TV when he gave me the packet of chips, cornflakes, and chocolate. I had to wish him that moment.

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-19) Kirti Mohan is a drop-out



Index of Journals
January 19, 2011

I was running lose in the morning. I took to study English, and then I was typing the photo-copied notes on laptop. It was consuming time, I decided to break off to do reading, and then I fell asleep for about two hours or so. I woke up at around six-thirty and I was watching television till now (2040). 

Sometimes when Srishti or Prashant come out to watch my shows with me already there, it feels like ‘what to do now’. But then I do nothing, because if I influence them, it should not be a problem for me. Because at the end of the day they too are a part of the society, so let’s start cleaning it up starting from home. And like Lil’ Wayne said, “We all in a race. I’m just another sprinter. If there’s no finish line… Then who’s the real winner?”

I never talk about people behind their back with anybody. But I yesterday did that. While talking to Kirti Mohan I discussed Kanika Sahni’s bad behavior with him. It is not the usual me who’d do that. Well, it just happened, and it wouldn’t happen again.
And oh my god, Kirti is a drop-out! He just let me know.

Last night I was listening to music on low volume and today in the morning, Prashant was playing his alarm sounds on high volume when I was sleeping. Somebody shut this idiot, man! Then his mother was complaining to me about playing music at night, as if it’s my every day practice. 

God Bless ‘Me’
Ashish
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-18) Physics Exam



Index of Journals
18 January 2011

I was awake whole night. I had to cover syllabus for making it for four units and also to make it sure I revise the read topics once. I reached college and sat on the staircases of that building once again. 
There were MAIT students dressed in suits coming up with file-folder in their hands in cars. I learned they had job-interview and test for the same. I wondered about my college, NIEC (ADGITM) and wondered about my own future. Nah, I am not running for any job but it’s good if it’s coming.

Faizan came by and we revised for some time together. I wanted to go to toilet but I didn’t. I was feeling sick of hangover from last night, but I didn’t show up. The teacher didn’t allow me to go to toilet once he had given me the answer sheet. I didn’t bother to go later, waste of time. 

(Earthquake was felt just now, 0200 19 January 2011. I was sitting and my head starts shaking. I thought if I am getting shocks in head. Then I lifted my head from the laptop screen and found that fan was oscillating. I was terrified for a moment and I muted the laptop and sat dreaming about the next. Next was nothing. In a minute, the building was back to stable. There was noise of a woman from outside and I went out in the balcony for a second. So, the earthquake was confirmed.)

I found the exam to be too lengthy. I missed the Unit 4. I missed a Unit 3 numerical, and I knew how to do them. Oh god, I am in loose condition again. I need 35 and I attempted paper of 48 marks. So I am feeling neither good, nor bad. I am just not feeling okay as well.

After exam, I went to NIEC (now ADGITM) to issue book for next exam. I was accompanied by Kirti Mohan. Uh, while sitting in three-wheeler I tore a little stitch next to the side-pockets. It made me feel bad for hours. My mood was already down because of physics paper and now this blow to my mental being was intolerable. I kept going and doing my things quietly though.
I only felt relief when amma told me that she could stitch the cut back.

In the afternoon buaji was here to take kids back home, and I found her a little too happy in making a verbal connection with me. There surely must be some reason but I don’t want to know. That’s because sooner, or later, the things will change.

I was sleeping from 1700 to ten-thirty. I was thinking about all that happened during the day. At the metro station (Rithala), I was emptying my pockets into my bag and I saw that Kanika Sahni stood straight in my line of sight ahead at a distance. Well, I was looking for Faizan and Neha who were about to come. But then I saw this pretty lady. And I guess I caught her eye because she was looking here. Then she moved behind that person (one of her classmate) with whom she was talking. That was direct indication of the fact that she had noticed me for at least once, but I couldn’t understand for hours what that show of baseless confidence was for? She has a looks very strikingly similar to Anshu ma’am who in turn looks a copy of another Bollywood actor, Anushka Sharma.

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-17) Preparation for exams



Index of Journals
January 17, 2011

I am again short of time. If I don’t revise all the topics done then it would be useless to even count them. It is 0003 right now, means the date has already changed, oh god!

Okay, I had been taking the subject lightly. During these preparatory leaves, I was going for walks, I was never dropping my music-phone away, and I was watching television shows, what else would happen on the day before exam?

Manju buaji was here in the afternoon. She came with babaji who had been to court in the new car, SX4. She kept saying about it. I had never touched pen and notebook for preparing for exam but tonight I will. 
This girl Anushka comes here and she is a mere waste of time, trust me. 

Oh god, one chapter still left...

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Saturday, September 4, 2021

Journal (2011-Jan-16) Aunt's new phone and uncle left



Index of Journals
January 16, 2011

Yesterday, in the park where I go for walk, I was met by this person Anil Yadav. I didn’t want to talk but then chose not act awkward to shoo him away. What interested me in him was that he was doing some management course from NIIT and was also preparing for MBA entrance tests. Nothing else, it was the first time that I talked to anybody there. Otherwise, he was just another outsider in Delhi. He was again from U.P., Agra.

Yesterday in the morning, Anushka and Prashant together in the room and when Anushka was toying with my phone (caring nothing about its, Sony Ericsson w350i, flap) Prxnt was interestingly watching when the wrong would happen. I had to shout at Anushka to get my phone back and I didn’t mind being very harsh and rude to her. I was actually mad at Prashant’s act though.

Last night, chachi-chacha and Srishti went to get a new phone for chachi. It was very irritating to hear Srishti asking for phone worth R10000 in the evening before they left. But then chachaji must have told her some story to shut her up.


Today chachaji left. Though amma had called me to come out but I didn’t. That’s because neither I wanted to, nor chachaji would have mind.

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-15) Brilliant Tutorial Bills



Index of Journals
January 15, 2011

I just threw the bills piled up in my drawer for some time now (earlier amma had them). The bill of admission-cum-scholarship test, the bill of payment made as fees at Brilliant Tutorials. ‘Rs 500 as for test on 29th April 2008’ and ‘Rs 37068 as year-long tuition fees on 3rd May 2008’ read the bills. Amma always said fifty-thousand to put burden on me. But it was not. I got the scholarship of Rs 10000 and babaji had got another 3000 reduced by showing the papers of (Babbu) dad’s no-income at the office.
It used to feel bad, but now it doesn’t. Now, it is like ‘how is it wrong?’

Lately, I was happy to see that Achal Kaushik accepted my friend request after almost a year. It will help me put down past moments better. I made a separate Facebook profile for such contacts from my past, keeping in mind that I don’t connect to them or let them join me on my profile for current college (NIEC / ADGITM) friends.
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-14) Grandpa's health



Index of Journals
14 January 2011

Babaji’s ill health... Chachaji’s new avatar... Chachiji is bad as ever... Physics exam is four days far...

“What problem do chachiji have if heater remains on for a couple more minutes in babaji’s room?”
“What problem does she have with me warming hands before it (though I never did it, but I know her problem by the look of her ugly face)?”
“I remember from previous months, she used to take iron-machine to her room when I would be in amma’s room early in the morning... This woman is totally sick!”
“It’s irritating to always find her peeking from the sleek space left between closed door of amma’s room...”

“Chachaji is acting like he holds no grudge against me and it’s just me who is holding the grudge now; looks like he is giving up on me but I am not slowing down for anyone.”

“I have seen babaji sleeping in his weak health and I wonder if he is breathing or not. It’s really awful to see him this weak in his sleep, it’s really awful.”

“Physics re-exam is on 18th, I had pretty much time but now I am again felling short of it. I was on internet till evening since 0200 last night and then I didn’t get over with the running-nose and cold because of irregular sleeping time. Plus, I had nightfall at six in the morning, so it left me tired through out the day.”

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Journal (2011-Jan-13) Day of Lohri



Index of Journals
13 January 2011

It is Lohri today. Gurarchi had texted last night. 

Hardik’s call came just minutes before nine (2100). I had no plans to go out but then I did, and that is I. Yeah, he told me the stories of his recent life. It was politics going on in the society, his father’s ill health, Naina, and all that stuff. It was over-all fun to talk to him. In the end when he asked if we were meeting soon again, I said no. Of course, not, we discussed topics from months in mere an-hour-and-half, what would we talk if meet again in three days!

Sometimes I listen to those tracks of Eminem which I used to when I ended up Sonal’s chapter. And pass some time in the recollection of a sadly-ended-story of my one-sided love. Tracks in the playlist follow like this, Love the Way You Lie (by Rihanna ft. Eminem), 'Love the Way You Lie' (by Eminem ft. Rihanna), 'Space Bound', and ‘25 To Life.’ It was surprising when I thought I heard Sonal outside and rushed to the balcony door yesterday afternoon. I didn’t confirm if I was right or wrong.

Babaji is having a bad time with his health. He is struck by cold. We had to consult doctor for supervision. 

Buaji was here to collect Prachi and Anushka but I was in my room. So I didn’t see her. And anyways I didn’t want to either. Plus, this feeling is mutual between us.

And at the end the day I wish I could get out this house early as possible.

God Bless ‘Me’
Ashish 
Tags: Behavioral Science, Emotional Intelligence, Indian Politics, Journal, Management, Politics, Psychology

Friday, September 3, 2021

Two Types of Matrix Multiplication Using NumPy



How are two matrices multiplied according to the math rules: Khan Academy

(base) C:\Users\ashish>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> a = [[1, -1], [1, 2]]
>>> b = [[3], [4]]

>>> a * b
Traceback (most recent call last):
  File "[stdin]", line 1, in [module]
TypeError: can't multiply sequence by non-int of type 'list'

>>> a = np.array(a)
>>> b = np.array(b)

>>> a
array([[ 1, -1],
       [ 1,  2]])

>>> b
array([[3],
       [4]])

>>> np.matmul(a,b)
array([[-1],
       [11]])

>>> np.matmul(b, a)
Traceback (most recent call last):
  File "[stdin]", line 1, in [module]
ValueError: shapes (2,1) and (2,2) not aligned: 1 (dim 1) != 2 (dim 0)

>>> a.dot(b)
array([[-1],
       [11]])

>>> np.dot(a, b)
array([[-1],
       [11]])

>>> a.b
Traceback (most recent call last):
  File "[stdin]", line 1, in [module]
AttributeError: 'numpy.ndarray' object has no attribute 'b'

>>> np.dot(b, a)
Traceback (most recent call last):
  File "[stdin]", line 1, in [module]
ValueError: shapes (2,1) and (2,2) not aligned: 1 (dim 1) != 2 (dim 0)

# How about an element to element multiplication?
# Note: this is not how math books do it

>>> np.multiply(a, b)
array([[ 3, -3],
       [ 4,  8]])

>>> np.multiply(b, a)
array([[ 3, -3],
       [ 4,  8]])

>>> a*b
array([[ 3, -3],
       [ 4,  8]])

>>> a = [[1, 1], [2, 2]]
>>> b = [[0, 0], [1, 1]]
>>> a = np.array(a)
>>> b = np.array(b)
>>> a*b
array([[0, 0],
       [2, 2]])

>>> a = [[0, 1], [2, 3]]
>>> a = np.array(a)
>>> b = [[5, 10], [15, 20]]
>>> b = np.array(b)
>>> a*b
array([[ 0, 10],
       [30, 60]])
>>>

Ref: docs.scipy.org

Tags: Technology,Python,NumPy

Using NumPy's 'random' package (randint and shuffle)



randint

>>> np.random.randint(4) 0 >>> np.random.randint(4) 3 >>> np.random.randint(4) 2 >>> np.random.randint(4) 0

shuffle

>>>arr = np.arange(10) >>>np.random.shuffle(arr) >>>arr [1 7 5 2 9 4 3 6 0 8] # random - - - >>> import numpy as np >>> arr = [0, 1, 2, 3] >>> np.random.shuffle(arr) >>> arr [1, 0, 2, 3] >>> np.random.shuffle(arr) >>> arr [0, 1, 3, 2] >>> Tags: Technology,Python,NumPy

Dot Product using Python, NumPy, Matplotlib



Dot product / Inner product / Scalar product

Algebraic Definition
Geometric Definition
Python Code
from matplotlib.pyplot import plot point1 = [0, 0] point2 = [3, 0] x_values = [point1[0], point2[0]] y_values = [point1[1], point2[1]] plot(x_values, y_values, 'b-') # format: Blue dashes point1 = [0, 0] point2 = [3, 3] x_values = [point1[0], point2[0]] y_values = [point1[1], point2[1]] plot(x_values, y_values, color='red', marker='o')
import numpy as np a = np.array([3, 0]) b = np.array([3, 3]) c = np.array([1, 1]) print("a, b, c:", a, b, c, end = "\n\n") print("a.dot(b):", a.dot(b)) print("b.dot(a):", b.dot(a), end = "\n\n") print("np.dot(a, b):", np.dot(a, b)) print("sum(a*b):", sum(a*b), end = "\n\n") print("np.dot(b, c):", np.dot(b, c)) print("sum(b*c):", sum(b*c), end = "\n\n") theta = np.pi / 4 print("theta = np.pi / 4") print("np.linalg.norm(a) * np.linalg.norm(b) * np.cos(theta):", np.linalg.norm(a) * np.linalg.norm(b) * np.cos(theta)) a, b, c: [3 0] [3 3] [1 1] a.dot(b): 9 b.dot(a): 9 np.dot(a, b): 9 sum(a*b): 9 np.dot(b, c): 6 sum(b*c): 6 theta = np.pi / 4 np.linalg.norm(a) * np.linalg.norm(b) * np.cos(theta): 9.0 Tags: Technology,Python,Data Visualization,Machine Learning,

Google Sites, Tor Exit Nodes and Captcha



Top 10 Websites

Rank - Website - Monthly Visitors - Country of Origin - Category 1 Google.com 92.5B U.S. Search Engines 2 Youtube.com 34.6B U.S. TV Movies and Streaming 3 Facebook.com 25.5B U.S. Social Networks and Online Communities 4 Twitter.com 6.6B U.S. Social Networks and Online Communities 5 Wikipedia.org 6.1B U.S. Dictionaries and Encyclopedias 6 Instagram.com 6.1B U.S. Social Networks and Online Communities 7 Baidu.com 5.6B China Search Engines 8 Yahoo.com 3.8B U.S. News and Media 9 xvideos.com 3.4B Czech Republic Adult 10 pornhub.com 3.3B Canada Adult ... 41 Walmart.com 718.6M U.S. Marketplace 42 Bilibili.com 686.0M China Animation and Comics 43 Tiktok.com 663.2M China Social Networks and Online Communities 44 Paypal.com 657.2M U.S. Financial Planning and Management 45 Google.de 624.5M Germany Search Engines 46 Amazon.co.jp 619.2M Japan Marketplace 47 Aliexpress.com 611.0M China Marketplace 48 Amazon.de 608.8M Germany Marketplace 49 Rakuten.co.jp 593.4M Japan Marketplace 50 Amazon.co.uk 579.7M United Kingdom Marketplace

Top 50 Websites

Google.com

YouTube

2021-Sep-02
2021-Aug-24

survival8.blogspot.com

Ref: visualcapitalist Tags: Technology,Cyber Security,Web Scraping,

Wednesday, September 1, 2021

Extracting Text from Docx, Doc and Pdf files Using Python




import os
import docx # pip install python-docx # Does not support .pdf and .doc
import PyPDF2

from docx import Document

SUPPORTED_FORMATS = ['pdf', 'doc', 'docx']
WORD_FORMATS = ['doc', 'docx']

For DOCX

f_list = [] for dirpath, subdirs, files in os.walk("."): for f in files: if f.split(".")[1] == "docx" and f[0] != "~": f_list.append(os.path.join(dirpath, f)) d_list = [] for f in f_list: d_list.append(Document(f)) t_list = [] for d in d_list: para_text = "" for para in d.paragraphs: para_text = para_text + " " + para.text t_list.append(para_text)

FOR PDF

f_list = [] for dirpath, subdirs, files in os.walk("."): for f in files: if f.split(".")[1] == "pdf" and f[0] != "~": #print(f, dirpath) f_list.append(os.path.join(dirpath, f)) d_list = [] t_list = [] for f in f_list: pdfFileObj = open(f, 'rb') pdfReader = PyPDF2.PdfFileReader(pdfFileObj) d_list.append(pdfReader) text = "" for pageObj in pdfReader.pages: text = text + " " + pageObj.extractText() t_list.append(text) pdfFileObj.close()

For DOC

import win32com.client word = win32com.client.Dispatch("Word.Application") word.visible = False wb = word.Documents.Open(r'D:\xyz.doc') doc = word.ActiveDocument print(doc.Range().Text) Tags: Technology,Python,Natural Language Processing,

Managing task on Windows using CMD



Managing task on Windows using CMD using "tasklist", "taskkill" and "findstr".

(base) CMD>tasklist | findstr "WINWORD*"
WINWORD.EXE --  3164 Console --   7    251,092 K
WINWORD.EXE --  9292 Console --   7    245,508 K
WINWORD.EXE -- 13640 Console --   7    246,748 K
WINWORD.EXE -- 10288 Console --   7    242,704 K
WINWORD.EXE -- 19244 Console --   7    246,996 K
WINWORD.EXE -- 18416 Console --   7    246,552 K
WINWORD.EXE -- 12380 Console --   7    163,932 K

(base) CMD>taskkill /F /PID 3164
SUCCESS: The process with PID 3164 has been terminated.

(base) CMD>taskkill /IM "WINWORD.exe" /F
SUCCESS: The process "WINWORD.EXE" with PID 13640 has been terminated.
SUCCESS: The process "WINWORD.EXE" with PID 10288 has been terminated.
SUCCESS: The process "WINWORD.EXE" with PID 19244 has been terminated.
SUCCESS: The process "WINWORD.EXE" with PID 18416 has been terminated.
SUCCESS: The process "WINWORD.EXE" with PID 12380 has been terminated.

Tags: Technology,Windows CMD,

Convert MS Word files into PDF format using Python on Windows




import os
import PyPDF2

import sys
import comtypes.client

SUPPORTED_FORMATS = ['pdf', 'doc', 'docx']
WORD_FORMATS = ['doc', 'docx']

f_list = []
for dirpath, subdirs, files in os.walk("."):
    for f in files:
        if f.split(".")[1] in WORD_FORMATS and f[0] != "~":
            f_list.append(os.path.join(dirpath, f))
        

"""
The following code converts "doc" and "docx" files to "pdf". But once it opens the files, due to some issue in our code
(usually an unattended Word prompt) it does not closes the files properly and the Operating System file lock 
remains open on the file. So the code runs for one time but not the second time unless we end the "Word" program 
instances from the Task Manager.
"""

os.system('taskkill /IM "WINWORD.exe" /F')
wdFormatPDF = 17

for f in f_list:
    in_file = os.path.abspath(f)
    out_file = in_file.split(".")[0] + ".pdf".strip()
        
    word = comtypes.client.CreateObject('Word.Application')
    word.Visible = True
    
    doc = word.Documents.Open(in_file)
    
    doc.SaveAs(out_file, FileFormat=wdFormatPDF)

    #doc.Close()
    #word.Quit()
    os.system('taskkill /IM "WINWORD.exe" /F') 
    

Other Notes

import docx # pip install python-docx # Does not support .pdf and .doc Tags: Technology,Python,Natural Language Processing,