Sunday, May 15, 2011

Simple Commands on Linux(shell scripting in unix)

1- how open new file in shall
- vi  file-name.sh
after opening a new file, for inserting command press : shift+i
for saving the commands in  file and  exit press: ESC+Shift+: +q

2- how delete special lines(rows)  from one file :

after pressing Esc+Shift+:   type :  1,1990d  and then press enter
with this command rows from 1 to 1990 will be delete from that file.

3- Running an batch file :
- first set permission for  running with the following command:
           - chmod 777(or 755)  filename.sh
- now run with the following command :
           - ./ filename.sh

for displaying list  just  run the following command :
        - LS

4- copying favorite number of lines from one file to other :
     head -1000 file2.txt > file3.txt
with  this command 1000  rows  from  file2.txt will be  copy to file3.txt.


all the best.


how you can create Bootable pen drive for installing Win7

hi
I faced a big problem last week.
My DVD did not work and win7 also had problem. i had  to change  win7.
I made a bootable  pen drive (4GB pen drive minimum  needs) with the following  commends.
All of the  commends  are available in :
http://www.blogger.com/goog_1040725359

On the Start menu, navigate to the command prompt entry. Right-click and select Run as administrator.
vista-command-prompt
Type
diskpart
list disk
Record the disk number of your USB flash drive.
vista-diskpart


This guide works 100% for Vista & Windows 7 unlike most of the guides out there. I have seen many sites/blogs that have “Install Vista from USB guide” but either with incomplete steps or not working guide. I have also seen some guides that don’t’ use proper commands in this guide. After spending many hours I have come up with this 100% working guide.
Bootable USB drive
I just did this method on one of my friends machine and installed the new Windows 7 BETA. The main advantage is that by using USB drive you will be able to install Windows 7/Vista in just 15 minutes. You can also use this bootable USB drive on friend’s computer who doesn’t have a DVD optical drive.
The method is very simple and you can use without any hassles. Needless to say that your motherboard should support USB Boot feature to make use of the bootable USB drive.
Requirements:
*USB Flash Drive (Minimum 4GB)
*Windows 7 or Vista installation files.
Follow the below steps to create bootable Windows 7/Vista USB drive using which you can install Windows 7/Vista easily.
1. Plug-in your USB flash drive to USB port and move all the contents from USB drive to a safe location on your system.
2. Open Command Prompt with admin rights. Use any of the below methods to open Command Prompt with admin rights.
*Type cmd in Start menu search box and hit Ctrl+ Shift+ Enter.
Or
*Go to Start menu > All programs > Accessories, right click on Command Prompt and select Run as administrator.
3. You need to know about the USB drive a little bit. Type in the following commands in the command prompt:
First type DISKPART and hit enter to see the below message.
Bootable USB Drive
Next type LIST DISK command and note down the Disk number (ex: Disk 1) of your USB flash drive. In the below screenshot my Flash Drive Disk no is Disk 1.
4. Next type all the below commands one by one. Here I assume that your disk drive no is “Disk 1”.If you have Disk 2 as your USB flash drive then use Disk 2.Refer the above step to confirm it.
So below are the commands you need to type and execute one by one:
SELECT DISK 1
CLEAN
CREATE PARTITION PRIMARY
SELECT PARTITION 1
ACTIVE
FORMAT FS=NTFS
(Format process may take few seconds)
ASSIGN
EXIT
Don’t close the command prompt as we need to execute one more command at the next step. Just minimize it.
Bootable USB Drive
5. Next insert your Windows7/Vista DVD into the optical drive and check the drive letter of the DVD drive. In this guide I will assume that your DVD drive letter is “D” and USB drive letter is “H” (open my computer to know about it).
6. Maximize the minimized Command Prompt in the 4th step.Type  the following command now:
D: CD BOOT and hit enter.Where “D” is your DVD drive letter.
CD BOOT and hit enter to see the below message.
7. Type another command given below to update the USB drive with BOOTMGR compatible code.
BOOTSECT.EXE /NT60 H:
14
Where “H” is your USB drive letter. Once you enter the above command you will see the below message.
8. Copy your Windows 7/Vista DVD contents to the USB flash drive.
9. Your USB drive is ready to boot and install Windows 7/Vista. Only thing you need to change the boot priority at the BIOS to USB from the HDD or CD ROM drive. I won’t explain it as it’s just the matter the changing the boot priority or enabling the USB boot option in the BIOS.
Note: If you are not able to boot after following this guide means you haven’t set the BIOS priority to USB. If you got any problem in following this guide feel free to ask questions by leaving comment.

Just  restart your laptop and boot with pendrive and start for installation.
All the best




Thursday, January 27, 2011

Most Popular commands

Normalization :





Index:

----------------------------------------------------------------------------
---------------------------------------------------------------------

-------------------------------------------------------------------------

------------------------------------------------------------------------------

---------------------------------------------------------------------

---------------------------------------------------------------------


------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------


-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------


Some commands of MYSQL

hi
today  i would like  to  write  all SQL  commands  that  mostly  i am using in my  analysis.

1-  create  database :  
      mysql> create  database test_db;

2- enter  on  your  database:
      mysql> use  test_db;

3- deleting  all database:
     mysql>  drop  database  test_db ;

4- Create  table  :
     mysql>  create  table  login ( User_Id  varchar(18) ,  Time_Spent  int ,  hits  int , gender  char(1));

5- showing  the  name  of  all  tables  in the  database :
     mysql > show  tables;

6-deleting  table :
     mysql> drop  log_table;

7- show  the  structure of  tables :
     mysql> describe  table_name ;

8- changing  the  structure  of  tables (adding/ deleting  columns):
     mysql> alter  table table_name  DROP   column_Name ;
                                             or
     mysql> alter  table  table_name   add  Reg_No  varchar(18);

9- Inserting  rows  into  table :
     mysql> Insert  into  table_name  table_column_name     values ();

10-  loading  data  from  .txt  file  into  sql  table:
     mysql> load  data  local infile  "h:/pp.txt"  into  table table_name  fields  terminated  by ","  ;

11- make  one  table with  joining  two  other  table :
     mysql> create  tabel   NV  as (select  T.User_Id, S.Sname, S.Reg_No  from  Tool as  T,  Sol  as S       where  T.User_Id=S.User_Name) ;

12- Export  data  from  mysql  to   .txt  file :
     mysql> select  *  into  outfile  "h:/u.txt"  fields  terminated  by ","  from  NV   where  gender="f" ;

13- showing  favorite numbers  of  lines  from  table  in SQL :
     mysql>  select  *  from  table_name  limit  100 ;

14- Update  data :
     mysql> update  table_name  set  age=age+1 ;

15- delete  data  from   table :
     mysql > delete  from  table_name  where   state="ky"  ;

16- create  another  table based on one tables contents sum  :  
    mysql> select  customer_Id, count(distinct transactions) as  T, sum(quantity) as  items_bought , sum   (amount) as spendings   from  table1  group  by  customer_Id  order by spending desc;






  

Saturday, January 22, 2011

Write a Program in java for selecting Special Columns in a file which separated by space



/* open a file which includes columns separeted by "  "  and copy all content in other file  which  fields  separated by "," */

import  java.io.*;
import  java.util.*;

class SeparateColumns {
      public static void main(String  args[]){
            File inFile= new File("G:/Sign-Code/cpi.txt");
            File outFile=new File("G:/Sign-Code/cccpi.txt");
            FileReader ins= null;
            FileWriter outs=null;
            BufferedReader br=null;
            BufferedWriter bw=null;
           
            try { ins=new  FileReader(inFile);
                  outs=new FileWriter(outFile);
                  br=new BufferedReader(ins);
                  bw=new BufferedWriter(outs);
                  String temp[]=new String[7];  // shows number of column=7
                  String str;
                  while((str=br.readLine())!=null){
                    temp= str.split("\t");
                    bw.write(temp[0]);
                    bw.append(",");
                    bw.write(temp[1]);
                    bw.append(",");
                    bw.write(temp[2]);
                    bw.append(",");
                    bw.write(temp[3]);
                    bw.append(",");
                    bw.write(temp[4]);
                    bw.append(",");
                    bw.write(temp[5]);
                    bw.append(",");
                    bw.append(temp[6]);
                    bw.newLine();}
                    }catch(IOException e){}
                    finally {
                          try {
                                br.close();
                                bw.close();} catch(IOException e){}
                                            
                                    
      }          
      }
      }

Thursday, January 20, 2011

Import and Export .txt files to MYSQL

One of  the main poblems  related to work with SQL is :  exporting and importing  .txt files to  SQL.
I see myself  too many  websites and books for finding  a simple command  for this purpose , but most of them proposing  tools or  very difficult commands.
Myself  , i am  using  the following  simple command .

1- make a database :  create database name_db ;
          mysql> create database my_exper;

 Enter in  your  database :  Use  my_exper ;

2- make  a  table with your favorite number of  columns:  create table exper ( U_Id varchar(18), Reg_No varchar(8) , Mob_No  int , age int);

3- Import  data  from  .txt files on your  table  in  MYSQL :  [ in my .txt file fields  separated  by "," ]
            load data local   infile "d:/myfile/m.txt"   into table  exper   fields  terminated  by  ","  ;
some time  no neccessary  write  local word  on this command.

4- show tables from  my_exper ;
5- show  structure  of  your  table  : describe  exper ;
6- show  all  rows  in  your  table  : select  *  from  exper ;
 7-  Exporting    (saving )  MySQL   data  in .txt   file :
  select  *  into  outfile  "D:/my_results/mr.txt"   fields  terminated  by ","    from   exper where   age>40 ; 
  
I will be happy if  share with me  your  new  ideas.
Best  wishes

First Post

Hello
I am Rozita  , Phd  scholar in India.
My area  of  research is data mining,  web mining , social networking , behavior mining related to education data mining.

I have  problem  related forgetting  all my  own results related to my experience  on different  area of my study, so i decided  make  this  blog  for just  recording my all important results,  codes and  ...

I will be happy  if any one share with me her/his  idea  about different  related results .
best woshes