473,669 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reformating a csv table

1 New Member
Dear PERL users,
I am a biologist with a limited programming experience in the statistical programming language R . Recently I have been facing the task to extract relevant information from csv file with a size of 500MB and rewrite it as another csv with data organized in a different way. Although it is very easy to write a R program doing the desired manipulations, it is desperately slow. Because some 5 years ago I used PERL for very simple manipulation of DNA and protein sequences (one-shot job with a book dealing with PERL and sequences in hand) I got a feeling that PERL could be the right choice. I would like to kindly ask for help with my problem. I am not asking for a complete code, rather for an advice how to design the most efficient program (searching through the internet shows that in PERL task can be accomplished in a various manner but some of them are faster than others).

The problem is as follows:
For each level of Key1 and (its sub)Key2 get an array of MesuredValues across CellLinesA - CellLineZ. Key1 is (should be) unique, (sub)Key2 two can have various levels for Key1. Not all Key1(s) have the all levels of Key2. The file should be rather regular - there should always be all the cell lines A-Z (with MeasuredValue NA if the mesurement is missing) oredered in the same way A-Z, but this must be checked.

ORIGINAL csv
1 ,A , CellLineA, 0.1
1 ,A , CellLineB, 0.2
1 ,A , CellLineC, 0.3
1, B , CellLineA, 0.4
1 ,B , CellLineB, 0.5
1 ,B , CellLineC, NA
2 ,A, CellLineA, NA
2 ,A , CellLineB, 0.6
2 ,A , CellLineC, 0.7
3,............. .......


The Output Should Look Like
Key1,Key2,CellL ineA,CellLineB, CellLineC
1,A,0.1,0.2,0.3
1,B,0.4,0.5,NA.
2,A,NA,0.6,0.7
3.............. .


ORIGINAL csv -POSSIBLE IRREGULARITIES:
Key1,Key2,CellL ine, MeasuredValue
1 ,A , CellLineA, 0.1
1 ,A , CellLineB, 0.2
1 ,A , CellLineC, 0.3
1 ,B , CellLineB, 0.5
1, B , CellLineA, 0.4
2 ,A , CellLineC, 0.7
2 ,A , CellLineB, 0.6
3,............. ......


Thanks for help
Karpatov
Jan 5 '08 #1
1 1143
KevinADC
4,059 Recognized Expert Specialist
You will need to build a data set to parse and organize the data, then print it to file. A 500 MB file is probably going to consume a lot of system memory to build the data set, possibly giga-bytes of memory. Will the computer you run the program on have enough memory? And it will still take a while for perl to process a 500 MB file and do what you want. How long depends on too many things to attempt an estimate. Have you tried to write any code yet?
Jan 5 '08 #2

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

Similar topics

15
2658
by: Xah Lee | last post by:
Here's the belated Java solution. import java.util.List; import java.util.ArrayList; import java.lang.Math; class math { public static List range(double n) { return range(1,n,1); }
5
33630
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. Performance: 4 seconds, the system is doing a full-table scan of the second table, and the Explain Plan output
4
6590
by: Gaz | last post by:
Hi, I need to have a table nested within another table. The tables are alongside each other visually speaking, and the nested table (on the right) can vary in size. My problem is that when the nested table has more rows than the first table, the first table (on the left) pads out its rows so that the table matches the height of the nested table. I don't want this it happen.. I just want the nested table to be longer than the first...
10
7842
by: John | last post by:
I have a table with two rows. On the first row is a text box and in the second row is an image. I have set the table cellpadding to 0 and cellspacing to 0. The table is leaving extra spaces in the rows on the top and bottom of the picture and image. I need to make the height of the rows to be the same as the textbox and image. How do I do this? I have tried even setting the height of the table and all the <td> and <tr> tags to 1 but have...
61
24464
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will 'stretch'</td> <td valign="top" width="300">some data that won't 'stetch'</td> </tr> </table>
9
2758
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with each having 3 fields each, their own PK; the FK back to the parent table; and the unique data for that table. There is a one to many relation between the parent and each of the 9 child rows. Each child table has between 100,000 and 300,000
0
1088
by: Rookie Card | last post by:
Issue - Reformating the Dates in ASP.NET from a MSSQL Database that has <NULL> values in a SmallDateTime Field to read "Dec 8, 2000" instead of "12/8/2000 12:00:00 AM" (As you might already know "DateTime.Parse" will throw an exception when it comes accross a <NULL> date value so some logic has to be written.
7
4811
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the expandable row, the hidden row is made visible with css. The problem is when i sort the rows, the hidden rows get sorted as well which i don't want and want to be moved (while sorting) relative to their parent rows. The following is my complete html code...
5
3839
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big table, we try separate this big table into twelve tables and create a view
5
4933
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link: http://www.jaredmoore.com/tablesorter/docs/salestable.html Here is some jquery js that I think...
0
8894
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8803
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8587
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5682
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
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 we have to send another system
2
2029
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.