Extract certain columns from big data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract certain columns from big data
# 1  
Old 06-14-2013
Display Extract certain columns from big data

The dataset I'm working on is about 450G, with about 7000 colums and 30,000,000 rows.
I want to extract about 2000 columns from the original file to form a new file.
I have the list of number of the columns I need, but don't know how to extract them.
Thanks!
# 2  
Old 06-14-2013
Is the file delimited (like with commas between field) or fixed record length?
This User Gave Thanks to joeyg For This Post:
# 3  
Old 06-14-2013
happypoker,
You can use gnu awk and use array for the desired columns to store and print the data.
This User Gave Thanks to rveri For This Post:
# 4  
Old 06-14-2013
Quote:
Originally Posted by joeyg
Is the file delimited (like with commas between field) or fixed record length?
Sorry I didn't make it clear.
Yes, the file is tab delimited.
# 5  
Old 06-14-2013
If you can post a sample data it may be helpful to determine the actual code.
# 6  
Old 06-14-2013
You want some columns, all rows, not keyed by some columns, some values? I'd say 'cut' but I have found cut disappointing in speed in some situations. No chance the rows or columns are fixed length? I'd go with C, mmap() and a 64 bit compile, but awk sounds like a good fit: field oriented and delimiter configurable.

Tools like Ab Initio would divide the file into N byte blocks and process it in parallel. You could do the same, if you write a script that seeks and only goes so far, but it gets tricky ensuring the row containing byte N+1 is processed by the first instance, as it must be ignored by the second instance, since it might be (and probably is) partial and belongs to the prior instance. Or not, you get to decide who owns that row. My thought is that every instance goes N+1 bytes, ignoring the first line if not the first instance, and beyond N+1 to get the end of the last line.

Welcome to big data.
# 7  
Old 06-14-2013
Quote:
Originally Posted by rveri
happypoker,
You can use gnu awk and use array for the desired columns to store and print the data.
Thank you! I'm able to get the list column # into an array, but still don't know how to print those corresponding columns out.

The data is something like:
Code:
000 A B C D 2.22 3.4 1.03 .....
001 B F S D 3.2 2.1 3.2 2.3 .....
....
...
132 F S F X 2.3 3.4 5.3 2.1 ....

It has about 6600 columns and 30,000,000 lines. It's too big to put the needed columns in some array, I have to print the needed columns line by line.

Last edited by Scrutinizer; 06-17-2013 at 03:10 AM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract Big and continuous regions

Hi all, I have a file like this I want to extract only those regions which are big and continous chr1 3280000 3440000 chr1 3440000 3920000 chr1 3600000 3920000 # region coming within the 3440000 3920000. so i don't want it to be printed in output chr1 3920000 4800000 chr1 ... (2 Replies)
Discussion started by: amrutha_sastry
2 Replies

2. Shell Programming and Scripting

Want to extract certain lines from big file

Hi All, I am trying to get some lines from a file i did it with while-do-loop. since the files are huge it is taking much time. now i want to make it faster. The requirement is the file will be having 1 million lines. The format is like below. ##transaction, , , ,blah, blah... (38 Replies)
Discussion started by: mad man
38 Replies

3. Shell Programming and Scripting

Compare 2 csv files by columns, then extract certain columns of matcing rows

Hi all, I'm pretty much a newbie to UNIX. I would appreciate any help with UNIX coding on comparing two large csv files (greater than 10 GB in size), and output a file with matching columns. I want to compare file1 and file2 by 'id' and 'chain' columns, then extract exact matching rows'... (5 Replies)
Discussion started by: bkane3
5 Replies

4. What is on Your Mind?

Big Data for System Admins

Hello, I have been working as Solaris/Linux Admin since past 8 years. I am looking options for my profile change, but there is some limitation. I worked as 24x7 support for admin, server support, high availability, etc. But been worked on developing side and scripting part. When I search for Big... (2 Replies)
Discussion started by: nightup2222
2 Replies

5. Shell Programming and Scripting

Extract certain entries from big file:Request to check

Hi all I have a big file which I have attached here. And, I have to fetch certain entries and arrange in 5 columns Name Drug DAP ID disease approved or notIn the attached file data is arranged with tab separated columns in this way: and other data is... (2 Replies)
Discussion started by: manigrover
2 Replies

6. Red Hat

Linux in Big Data projects

Hey guys, we will be interested in learning from your experience in using Linux in Big Data projects. Has anyone used Hadoop, or MapR or Horton Works on Linux and any experiences you may have had on these. I am more interested in knowing if a certain distribution of Linux is better supported for... (1 Reply)
Discussion started by: johnsmith111
1 Replies

7. Shell Programming and Scripting

Sort a big data file

Hello, I have a big data file (160 MB) full of records with pipe(|) delimited those fields. I`m sorting the file on the first field. I'm trying to sort with "sort" command and it brings me 6 minutes. I have tried with some transformation methods in perl but it results "Out of memory". I was... (2 Replies)
Discussion started by: rubber08
2 Replies

8. Shell Programming and Scripting

Transpose columns to Rows : Big data

Hi, I did read a few posts on the subjects, tried out a few solutions, but did not solve my problem. https://www.unix.com/302121568-post11.html https://www.unix.com/shell-programming-scripting/137953-large-file-columns-into-rows-etc-4.html Please help. Problem very similar to the second link... (15 Replies)
Discussion started by: genehunter
15 Replies

9. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

10. Shell Programming and Scripting

How to cut some data from big file

How to cut data from big file my file around 30 gb I tried "head -50022172 filename > newfile.txt ,and tail -5454283 newfile.txt. It's slowy. afer that I tried sed -n '46467831,50022172p' filename > newfile.txt ,also slow Please recommend me , faster command to cut some data from... (4 Replies)
Discussion started by: almanto
4 Replies
Login or Register to Ask a Question