But here, I need to split the csv file by giving file-size(in KB) as
input.

It required to split as per size(in KB), instead of giving no. of files.

 

Suppose, even if the file size ends in the middle of the last line, it
should include the complete last line.

For eg:

 

NAME  AGE  PLACE

A              10    USA

B              12    UK

C              15    INDIA

D              20    AUS

 

Here, if the given file size is exceeding  in the 3rd row at "AGE"
column, then I need to complete that particular line and need to start
split from the next line.

 

-          Could you please help me ?

 

-          Thanks

Antony.

 

 

From: Bharat Warule [via R]
[mailto:ml-node+s789695n4639883...@n4.nabble.com] 
Sent: Friday, August 10, 2012 3:42 PM
To: Akkara, Antony (GE Energy, Non-GE)
Subject: Re: Split CSV as per file size

 


check this! if it helps! 

read_data <- read.csv(DataMatrix) 
length <- dim(read_data)[1] 
no_of_files <-  10 ##user define 
file_no_itr <- length/no_of_files 

for(i in 1:no_of_files){ 
        e_l <- i*file_no_itr 
    s_l <- 1 + (i-1)* file_no_itr 
        if(i==no_of_files){ e_l <- length} 
        read_data_new <- read_data[s_l:e_l,] 
        newname <- paste("read_data",i,sep="_") 
        assign(read_data_new,newname) 
        ### write ur output data code 
        } 

Bharat Warule 
Cypress Analytica , 
Pune 

 

________________________________

If you reply to this email, your message will be added to the discussion
below:

http://r.789695.n4.nabble.com/Split-CSV-as-per-file-size-tp4639880p46398
83.html 

To unsubscribe from Split CSV as per file size, click here
<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscrib
e_by_code&node=4639880&code=YW50b255LmFra2FyYUBnZS5jb218NDYzOTg4MHwxNTUx
OTQzMDI5> .
NAML
<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_view
er&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.Bas
icNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.tem
plate.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml
-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai
l.naml>  





--
View this message in context: 
http://r.789695.n4.nabble.com/Split-CSV-as-per-file-size-tp4639880p4641556.html
Sent from the R help mailing list archive at Nabble.com.
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to