Tuesday, May 24, 2016

0

R packages installation error solved

  • Tuesday, May 24, 2016
  • Most of the common error we are getting below  in R at the time of installing in R packages like(rJava,ggplot2...)




    Warning message:
    package ‘rJava’ is not available (for R version 3.0.2)


    In this post we ll see how to resolve this error.

    First login as root user 
    and type R and you ll get r prompt
    >

    then type 
     install.packages("rJava")
    it ll ask package mirror location give any one it ll installed without any issue.


    To confirm the package installation 
    try below line
    library(rJava)
    It won't throw any message so its installed .

    Read more...

    Thursday, April 28, 2016

    0

    Install R in Redhat 7.2

  • Thursday, April 28, 2016
  • Installation of R in redhat is simple.
    First download the below file

    wget http://public-yum.oracle.com/public-yum-ol7.repo

    open the downloaded file and change enabled property into 1
    vi public-yum-ol7.repo

    [ol7_latest]
    enabled=1
    
    [ol7_addons]
    enabled=1
    [ol7_optional_latest]
    enabled = 1

    then
     sudo yum install R.x86_64

    Now R is installed.. 
    typr R you ll get 

    R>
    error:

    If you are getting below error 
     
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
     
    GPG key retrieval failed: [Errno 14] curl#37 - "Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle"

     
    Try the below command to download oracle gpg file
    
    
     
    wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
    then
    sudo yum install R.x86_64
     
    issue has resolved..

    
    
    Read more...

    Friday, January 29, 2016

    0

    Convert Excel file data in to comma seperated text file

  • Friday, January 29, 2016


  • Below code is to convert excel file (name.xls) in to text files sepetated values by comma.
    In my name.xls file contains 6 columns and 20 rows (20 student informations) it has two different school details in sheet1 and sheet2


    package com.excel.upload;

    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import jxl.Cell;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.read.biff.BiffException;

    public class ExcelRead {

    public static void main(String[] args) {
           
           try {
               
                Workbook wrk1 =  Workbook.getWorkbook(new File("C:\\Users\\jayakumark\\Downloads\\test1.xlsx"));
               
               //i for number of row ,j for column , k for number of sheets in excel bassed on that you can change i, j, k values  here i am using 2 sheets
                int i,j,k;
                for(k=0;k<2;k++)
                {
               Sheet sheet1 = wrk1.getSheet(k);            
                      
               for (i=0;i<20;i++)
               {
                String [] crits = new String [6];
                for (j=0;j<=5;j++)
                {
                     Cell colArow1 = sheet1.getCell(j, i);      
             
                     String str_colArow1 = colArow1.getContents();
       
                     
                      crits[j] = str_colArow1;
                }
                   
       
         try{
                //to print those values in text file
                   OutputStreamWriter writer = new OutputStreamWriter(
                         new FileOutputStream("C:\\Users\\jayakumark\\Downloads\\DB_input_excel\\name.txt", true), "UTF-8");
                   BufferedWriter fbw = new BufferedWriter(writer);
                   fbw.write(crits[0]+"\t"+crits[1]+"\t"+crits[2]+"\t"+crits[3]+"\t"+crits[4]+"\t"+crits[5]");
                   fbw.newLine();
                   fbw.close();
               }catch (Exception e) {
                   System.out.println("Error: " + e.getMessage());
               }
               System.out.println("Contents of cell Col A Row 1: " +crits[1]);
           System.out.println("Done");
               }
                }
           } catch (BiffException e) {
               e.printStackTrace();
           } catch (IOException e) {
               e.printStackTrace();
           }
           

       }

    }

    here i -> number of rows
    j-> number of columns
    k -> number of sheets in excel
    if you have 5 sheets in your excel file you have to increase k value.
    Finally you will get all sheet values in a single text file .

    To use this code you should download and add below jar in your eclipse.
    jxl26jar

    Read more...

    Subscribe