hi,
I have a list which is read from a file - ['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']
-
i need to get the output in the form - ['48998','18:45:44','R','qp32']
-
['48999','0','Q','batch']
-
['49005','00:44:23','R','qp32']
-
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
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. - parsed_data = [[item[0].split(".")[0], item[3], item[4], item[5].strip()]
-
for item in [s.split(";") for s in data]]
- >>> print "\n".join([",".join(item) for item in parsed_data])
-
48998,18:45:44,R,qp32
-
48999,0,Q,batch
-
49005,00:44:23,R,qp32
-
49032,0,Q,qp32
-
49047,312:33:0,R,qp128
-
49052,0,Q,qp32
-
49053,0,Q,batch
-
49054,0,Q,batch
-
>>>
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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",...
|
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...
|
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
|
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>
|
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...
|
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...
|
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?
|
by: incredible |
last post by:
how to sort link list of string
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |