Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:57:30+00:00 2026-06-11T10:57:30+00:00

I have big .csv file. I would like to filter that file into a

  • 0

I have big .csv file. I would like to filter that file into a new table.

For example, I have .csv file as below:

   f1 f2  f3 f4  f5  f6 f7 f9  f10  f11 
t1  1  0  1   0  1  0   0  0   0    1 
t2  1  0  0   0  0  1   1  1   1    1 
t3  0  0  0   0  0  0   0  0   0    0 
t4  1  0  0   0  1  0   0  0   0    0 
t5  0  0  0   0  0  0   0  0   0    0 
t6  0  0  0   0  0  0   0  0   0    0 
  1. I have a table (as above)

  2. What I want to do is, I want to have new table for each row (meaning that, I will have new table for all rows. e.g, new table for row t1, new table for row t2, new table for row t3 and etc). As in this example, I should have 6 new tables.

  3. To develop new table for each row, there is a condition that need to meet. New table should look at every value in each column. And if the column has a same value with other column in other row (which is value 1), it should be grouped together.

As in this example, new table for t1 will consist t1,t2,t4 because value in column f1 have the same value (which is 1) with the value in f1 for row t2 and t4, also value in f5 is equal with the value in f5 for row t4, and value in f11 is equal with the value in f11 for row t2). So, thats mean, it will check every column. One of the output for should be like this:

       f1 f2  f3 f4  f5  f6 f7 f9  f10  f11 
    t1  1  0  1   0  1  0   0  0   0    1 
    t2  1  0  0   0  0  1   1  1   1    1 
    t4  1  0  0   0  1  0   0  0   0    0 
  1. As for t2, row t2 should be grouped with t4 because value in f1 in t1 and value f1 in t4 is equal. However, t2 should not consider the earlier row (as in this example, it should not consider t1). Output should be like this:

      f1 f2  f3 f4  f5  f6 f7 f9  f10  f11 
    t2  1  0  0   0  0  1   1  1   1    1 
    t4  1  0  0   0  1  0   0  0   0    0 
    
  2. Similar to other rows (row t3,t4,t5 and t6), it should look at every value in each column. And if the column has a same value with other column in other row (which is value 1), it should be grouped together.

  3. New table (with row and column header) should be then saved in a new .csv file. The file should be renamed using its row name. for example, as for t1, it should be saved as t1.csv.

  4. This is only a simple example. The proposed solution here will be applied in other big table of data. I need to read abc.csv file. Meaning that, it might be more than 100+ new table will be created (when I used original data).

so far i used this code:

a.files <- grep("^Task_vs_Files", dir(), value=TRUE) 
a.files

for(i in 1:length(a.files))
   dat <- read.table(file=a.files[i], header=T, sep=",", row.names=1) 


      (sapply(1:nrow(dat), function(x) if (dat[x,]==1)  #check row
            (sapply(1:nrow(dat), function(y) if (dat[,y]==1) #check column

            { 
                   write.csv( dat[(dat[[x,y]]==1 ) & (1:nrow(dat) >= x) , ] , file = paste("Files_", x) ) #save file based on row names
            } 
            else {NULL} ))

output from a.files:

[1] "Task_vs_Files_Proj.csv"  "Task_vs_Files_Whirr.csv"

dataset from one of the file (Task_vs_Files_Proj.csv)

       pom.xml. ZooKeeper.java HBase.java Hadoop.java. BasicServer.java. Abstract.java. HBaseRegion.java
WHIRR-25        1              0          1            0                 1              1                1
WHIRR-28        1              0          1            0                 0              1                0
WHIRR-55        0              0          1            0                 0              0                0
WHIRR-61        0              0          0            0                 0              1                0
WHIRR-76        0              0          1            0                 0              0                0
WHIRR-87        1              1          1            0                 0              1                1
WHIRR-92        1              0          0            1                 0              1                1

Appreciate help from the expert!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:57:31+00:00Added an answer on June 11, 2026 at 10:57 am
     sapply(1:nrow(dat), function(x) if (dat[x, "f1"]==1) { 
               write.csv( dat[ (dat[["f1"]]==1 )& (1:nrow(dat) >= x) , ])
                } else {NULL} )
    "","f1","f2","f3","f4","f5","f6","f7","f9","f10","f11"
    "t1",1,0,1,0,1,0,0,0,0,1
    "t2",1,0,0,0,0,1,1,1,1,1
    "t4",1,0,0,0,1,0,0,0,0,0
    "","f1","f2","f3","f4","f5","f6","f7","f9","f10","f11"
    "t2",1,0,0,0,0,1,1,1,1,1
    "t4",1,0,0,0,1,0,0,0,0,0
    "","f1","f2","f3","f4","f5","f6","f7","f9","f10","f11"
    "t4",1,0,0,0,1,0,0,0,0,0
    [[1]]
    NULL
    

    Will need to construct file names:

    invisible(
      sapply(1:nrow(dat), function(x) if (dat[x, "f1"]==1) { 
               write.csv( dat[ (dat[["f1"]]==1 )& (1:nrow(dat) >= x) , ] ,
                        file = paste0("fil_", x, ".csv") )
                                    } else {NULL} )
             )   
    

    If this is destined for Excel, as I fear it might be, note that the rownames are included but no column header will be created to designate the rownames.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big csv file ( about 30M ), that I want to
I have a very big CSV file (1GB+), it has 100,000 line. I need
I have a big csv file with datetime and value recorded every 10 seconds.
I have quite a big network in a CSV file. It containt 450k nodes
I have a moderate-sized file (4GB CSV) on a computer that doesn't have sufficient
I have a big csv file which lists connections between nodes in a graph.
I've written a big sql script that creates a CSV file. I want to
I have a big csv file where the first column is the day of
http://img32.imageshack.us/img32/6649/workspace1001.png big version I have this product data in a csv file, but some
I have some big .csv files and I am trying to put it into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.