473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Converting Text file into excel sheet

2
Following is the text file i have


Test logname : DISK$REGRES:[VERIFICATION.ACC]ACC_diff.log
FACILITY : ACC
FAILED LOGINACCOUNTINGTST
Total : 42
Passed : 41
Failed : 1
Not Run : 0

Test logname : DISK$REGRES:[VERIFICATION.BACKUP]BACKUP_diff.log
FACILITY : BACKUP
FAILED BACKUP_BEFORE
FAILED BACKUP_INTERCHANGE
Total : 34
Passed : 32
Failed : 2
Not Run : 0


I want to covert it into proper excel sheet (I attached the excel sheet)
Attached Files
File Type: xls sample324.xls (18.5 KB, 380 views)
Oct 8 '12 #1
1 2499
bvdet
2,851 Expert Mod 2GB
Have you attempted anything? I won't do your work for you. I will suggest the following steps:
Read the file.
Parse the data.
Initialize a dictionary to store the data in an organized fashion.
Iterate on the data.
If the line of data has a colon (:), split the data and add to dictionary as in:
Expand|Select|Wrap|Line Numbers
  1. >>> line = "FACILITY : BACKUP"
  2. >>> dd = {}
  3. >>> line_list = [item.strip() for item in line.split(":")]
  4. >>> line_list
  5. ['FACILITY', 'BACKUP']
  6. >>> dd.setdefault(line_list[0], []).append(line_list[1])
  7. >>> dd
  8. {'FACILITY': ['BACKUP']}
  9. >>> 
If the line of code contains "FAILED":
Expand|Select|Wrap|Line Numbers
  1. >>> line = "FAILED LOGINACCOUNTINGTST"
  2. >>> if "FAILED" in line:
  3. ...     dd.setdefault("FAILED", 0)
  4. ...     dd["FAILED"] += 1
  5. ...     
  6.  
  7. >>> dd
  8. {'FAILED': 1, 'FACILITY': ['BACKUP']}
  9. >>> 
After the data has been organized into a dictionary, create a CSV (comma separated value, the csv module is ideal for this) file for opening in Excel or write directly into Excel format with the xlwt module.
Oct 8 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Edward S | last post by:
I budget for a Project in an Excel sheet as illustrated below. The months below are usually a 2 year period i.e. 24 months, though it could be over 24 months depending upon a Project. I then...
0
by: dgoel | last post by:
Hi, I Have a text file & I want to open it in excel sheet ( withou importing). I have written code for it, but it is not opening exce sheet. It opens the text file, but does not create a excel...
0
by: Evan T. Basalik | last post by:
In my ASP.NET application, I have a table (really a datagrid) that I am converting into an Excel sheet using ContentType = "application/vnd.ms-excel". It seems to work fine for most of my results,...
1
by: Mike | last post by:
I need to search a server to see if files exist on that server or not. If the file does not exsit I need to write the filename to a text file, excel file, etc. what file acutally I have a list...
1
by: cawibm | last post by:
I need help with my table. When I import my text file, some of my records contain the negative symbol, indicating a negative number. If I change my import spec to number, these records get deleted....
6
by: vj83 | last post by:
Hi, I have a C#.net application in which i have read the datas from excel sheet and displayed in a datagrid in my Aspx form. The code is here private void Button2_Click(object sender,...
15
by: javadeveloper | last post by:
Can anybody help me with the code regarding how to convert a text file to JPG file... Its really urgent for me.. I was able to convert a text file to PDF.. But now I need to convert a text file to...
2
by: nalamveena | last post by:
I am able to export to excel through a stored procedure.But when i open it the datetime column and int columns are not getting recognised.
2
by: pulavarthipraveen | last post by:
Overview: We have a requirement in the c#.NET 1.0 windows application. There will be some input text file in the user’s machine. The user should browse and select the input text file and also select...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.