473,385 Members | 1,317 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,385 software developers and data experts.

split the list

hi,
I have a list which is read from a file
Expand|Select|Wrap|Line Numbers
  1. ['48998.tyrone-cluster;gic1_nwgs;mbupi;18:45:44;R;qp32\n', '48999.tyrone-cluster;gic2_nwgs;mbupi;0;Q;batch\n', '49005.tyrone-cluster;...01R-1849-01_2;mcbkss;00:44:23;R;qp32\n', '49032.tyrone-cluster;gaussian_top.sh;chemraja;0;Q;qp32\n', '49047.tyrone-cluster;jet_egrid;asevelt;312:33:0;R;qp128\n', '49052.tyrone-cluster;case3sqTS1e-4;mecvamsi;0;Q;qp32\n', '49053.tyrone-cluster;...01R-1850-01_1;mcbkss;0;Q;batch\n', '49054.tyrone-cluster;...01R-1850-01_2;mcbkss;0;Q;batch\n']
  2.  
i need to get the output in the form
Expand|Select|Wrap|Line Numbers
  1. ['48998','18:45:44','R','qp32']
  2. ['48999','0','Q','batch']
  3. ['49005','00:44:23','R','qp32']
  4.  
and each of this list is written into a file job.txt
till now i have tried split(".") but could not get the required output
Mar 4 '15 #1
1 1350
bvdet
2,851 Expert Mod 2GB
It appears your data is consistently formatted. A for loop or nested list comprehension should do it.
Expand|Select|Wrap|Line Numbers
  1. parsed_data = [[item[0].split(".")[0], item[3], item[4], item[5].strip()]
  2.                for item in [s.split(";") for s in data]]
Expand|Select|Wrap|Line Numbers
  1. >>> print "\n".join([",".join(item) for item in parsed_data])
  2. 48998,18:45:44,R,qp32
  3. 48999,0,Q,batch
  4. 49005,00:44:23,R,qp32
  5. 49032,0,Q,qp32
  6. 49047,312:33:0,R,qp128
  7. 49052,0,Q,qp32
  8. 49053,0,Q,batch
  9. 49054,0,Q,batch
  10. >>> 
Mar 4 '15 #2

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

Similar topics

5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
3
by: Matthew Walsh | last post by:
Whats wrong with the following code? using pythonWin I get the following error: Traceback (most recent call last): File "C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",...
5
by: Marie | last post by:
TblOptions OptionID Option There are 7 option records. If I have two subforms, how do I list the first 4 options in the first subform and the last 3 options in the second subform? Thank...
1
by: Booser | last post by:
// Merge sort using circular linked list // By Jason Hall <booser108@yahoo.com> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //#define debug
11
by: Neo | last post by:
Hi Frns, Could U plz. suggest me how can i reverse a link list (without recursion)??? here is my code (incomplete): #include<stdio.h>
4
by: MJ | last post by:
Hi I have written a prog for reversing a linked list I have used globle pointer Can any one tell me how I can modify this prog so that I dont have to use extra pointer Head1. When I reverse a LL...
6
by: rh0dium | last post by:
Hi all, I am having a bit of difficulty in figuring out an efficient way to split up my data and identify the unique pieces of it. list= Now I want to split each item up on the "_" and...
1
by: maxtoroq | last post by:
I know how to work the .FindAll method of the List class, but is there a way to split a list into 2 lists, one containing all the items that match a certain criteria and one that doesn't?
9
by: incredible | last post by:
how to sort link list of string
36
by: pereges | last post by:
Hi, I am wondering which of the two data structures (link list or array) would be better in my situation. I have to create a list of rays for my ray tracing program. the data structure of ray...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.