extract from a text file and convert it to dictionary - dictionary

I have a text file like the one uploaded and I want to extract information from it and convert it to a dictionary in Python like the example uploaded above.
But I was to extract information only if the the Status is up so the key should be the IP address and the value are the ports numbers. I tried many codes but none of them unfortunately worked. The code should be in Python. Thank you.
enter image description here
enter image description here

Related

Writing a program for a report card by entering the student's name and their respective marks by using key values generated by the user in dictionary

i wrote this code exactly shown in the youtube by the person.But he got the output and when I executed the code my syntax is error.whats the solution

Decode (encrypted/encoded) PDF417 Barcode information for Iraqi passport

I need to read PDF417 barcode for Iraqi passport and extract the information from it.
I scanned the barcode successfully and it contains two parts, first part is the MRZ and the second part is an encoded/encrypted text. so is there a way to know the method used to encode this text and how to decode it?
this is the encoded/encrypted part:
|Rk1SACAyMAAAAADcAAABYAF9AMUAxQEAAQA/IEBLAFt0AEBNAH98AEBZAJYAAEBjAMP8AEBmATj0AEB+AEmMAEClADEoAECLAC0oAECJAHEMAECqALQIAECLALgAAECoANsEAEB7AMiAAEB+AUF4AEDIAF0gAEDGAFCkAECzAFIgAECvAKeMAEDlAJQcAEDjAGQgAEDfAPUIAEDCAOOMAEC7AP8AAEDVAVEAAEDBAVCAAEDYASKAAIDFAT0AAED2AJqcAED8AJQcAEDsAQUEAEEVAPmUAEDqAVGEAA==|
Go to https://www.base64decode.org/, copy and paste your text and remove the bar | symbol from the beginning and ending. Then select ISO-8859-6 as the character set and click the DECODE button. You'd have to exclude certain characters from the result to piece together the actual contents.

Subscript and Superscript format data uploaded in Excel not showing

I want to import an excel sheet that contains data in subscript and superscript format. I want directly import the formula from Excel not by cropping as image. I am getting like this without any formating (a+b)2=a2+b2+2ab.
The application runs on the ASP.net framework and MS SQL database. Datatype for the column in SQL is nvarchar.
Appreciate if somebody can please help/guide me out of this issue.
Thank you!
If you view the Excel sheet and it looks like:
then what you are exporting is the string in the Formula Bar and not what you see in the cell. You need to modify the export to tell the destination app to display superscripting.
For example, if the destination app interprets HTML, then you should export:
(a+b)<sup>2</sup>=a<sup>2</sup>+b<sup>2</sup>+2ab
(its still a simple string, but the formatting instructions are part of the string)
If the destination app needs rtf, then a different format needs to be exported.

Retrieving only the first email of long email threads

I am new to R and I want to retrieve only the first email received from entire email threads. Each time an email is received in the inbox, a .csv file is created (i.e. I have many files of duplicated text, just differing by newest reply that is on the top of the .csv file)
I am not sure as to how I can provide my codes to help because right now, I don't have any idea how to even start on this segment of my data cleansing.
Is there a way for me to possibly group my .csv files based on the email thread they belong to, before extracting the most duplicated text (since the first email is likely to be present in all subsequent files) to be used in my corpus for topic mining?
Or does anyone have a better way to approach this? I have considered using the threads function in tm.plugin.mail but since these are plain texts, it only returns with a depth of 1 for every email.
EDIT:
The title of the files are just random strings of alphanumerals, and I only have a metadata containing the name of the sender, the date sent (no time provided), and the title of the file that it corresponds to. Here is an idea of what my data looks like:
From: xxx#gmail.com
To: yyy#gmail.com
Subject: Re: xxx
Dear Sir,
(main content)
Yours Sincerely,
xxx
From: yyy#gmail.com
To: xxx#gmail.com
Subject: xxx
Dear Sir,
(main content)
Regards,
yyy
Generally, this is how the .csv file will look like (except that with each comma, there is a new line break as per .csv files), so it is actually quite messy. There is no one fixed way that the email is being formatted, so I had a failed attempt in using regex to remove everything before the last instance of "From:". Some of the emails come in another format:
On (date), (time), (name) <email address> wrote:

Can I copy all tables from a URL?

My task is to copy tables from a public domain and format it later in Word. I have created a software where I just have to enter two values and the table is displayed to me on a web page. Then I have to copy this table into Word.
I was wondering if there was an easier way to achieve this....
I would even like to know if it is possible to store all the values I type to a TXT file or Excel sheet and programmatically copy the displayed web pages to Word.
Please help me and don't down-vote.....
Okay here are the detailed steps:
Open a webpage
Fill in a form with 4 fields
A new webpage opens based on what input you provide
Copy 2 tables from that webpage
Paste the 2 tables in MS Word 2007
Open browser again and go back to previous page
Enter new values in the webpage
Repeat all the steps
P.S There are more than 700 tables to be copied each week
I'm not sure this is what you need...anyway...
If you download the page (programmatically of course) you can parse it as XML (I assume it's a well-formed XML file otherwise you may have to use some dirty trick to find all tables). Then you can put all data on Word (by automation, you can even do all these stuffs from a Word macro, just download the HTML file, "parse" it to find tables and paste that text as HTML).
I would provide some example but it can't really be language-agnostic.

Resources