473,508 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to split a list file

1 New Member
I have a huge gene blast file, It looks like
gene1 40 0.5 1 20
gene2 30 0.4 3 30
....

I want to make it like this
['gene1','40','0.5','1','20']
['gene2','30','0.4','30','20']
I am a really a python newbie,so I don't know how to make it.

After this step, I want to filter the second value, if it larger than 20, I will output it.How could I do it in Python?
I am not quite sure my thinking is right or not.
Thanks a lot!
Feb 13 '11 #1
1 2052
bvdet
2,851 Recognized Expert Moderator Specialist
A file can be read one line at a time. Each line is read as a string. The line "gene1 40 0.5 1 20" can be split into a list with the string method split(). The second element in the list (list index 1) can then easily be evaluated for your output.
Expand|Select|Wrap|Line Numbers
  1. >>> line = "gene1 40 0.5 1 20\n"
  2. >>> lineList = line.strip().split()
  3. >>> int(lineList[1]) > 20
  4. True
  5. >>> 
Feb 13 '11 #2

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

Similar topics

12
5667
by: Martin Dieringer | last post by:
I am trying to split a file by a fixed string. The file is too large to just read it into a string and split this. I could probably use a lexer but there maybe anything more simple? thanks m.
4
18283
by: qwweeeit | last post by:
The standard split() can use only one delimiter. To split a text file into words you need multiple delimiters like blank, punctuation, math signs (+-*/), parenteses and so on. I didn't...
2
12799
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
1
2670
by: mia456789 | last post by:
I hv a mysql db in my RH linux , there is a very large table in the db , the file size is about 2G , how can I split the file into two files - two files physically and one file logically ? is ...
3
12364
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core...
2
1815
by: ownowl | last post by:
Hello beginer under python, I have a problem to get lines in a text file. lines have inside the \n (x0A) char, and le readline method split the line at this char too (not only at x0Dx0A). for...
1
2590
by: Chris Ashley | last post by:
I am working with some very large bitmap files (1700 * 60000) and need to split them into vertical strips. This is because GDI+ seems to load the entire file into memory and crashes with an out of...
1
11886
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?
1
9748
by: Query Builder | last post by:
I have one of our production Accounting Databases starting from 2 GB now grown into a 20 GB Database over the period of a few years... I have been getting timeouts when transactions are trying to...
1
4185
by: amit | last post by:
Hey guys I am trying to develop an application which would open an word file (.doc) and split it into multiple files. I want to create seperate file for tables, so the application should just...
0
7231
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
7133
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
7336
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
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
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,...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.