Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Merging two text files by a column Post 302548548 by evelibertine on Thursday 18th of August 2011 05:06:53 PM
Old 08-18-2011
Merging two text files by a column

So I have two text files. The first one looks like this:

refsnp_id chr_name chrom_start
1 rs1000000 12 126890980
2 rs10000010 4 21618674
3 rs10000012 4 1357325
4 rs10000013 4 37225069
5 rs1000002 3 183635768

And the second one looks like this:

AUC rs1000000 0.03 0.1240
AUC rs10000010 0.03 0.1462
AUC rs10000012 0.00 0.8628
AUC rs10000013 0.00 0.5459
AUC rs1000002 0.00 0.6439
AUC rs10000023 0.03 0.1337
AUC rs10000027 0.00 0.7142
AUC rs10000030 0.00 0.7634
AUC rs1000003 0.02 0.2226


The second columns of the two text files match but not completely. There are some missing lines in the first text file. I want to merge the two text files by their second columns and add the third and fourth column of the first file to the second file when the second columns of the two files are matching. How do I go about doing that? Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merging text files

hi, i need to merge 2 lakh text files ..... can somebody please help me with a script/program for it... (8 Replies)
Discussion started by: code19
8 Replies

2. Shell Programming and Scripting

Merging two files with a common column

Hi, I have two files file1 and file2. I have to merge the columns of those two files into file3 based on common column of two files. To be simple. file1: Row-id name1 13456 Rahul 16789 Vishal 18901 Karan file2 : Row-id place 18901 Mumbai ... (2 Replies)
Discussion started by: manneni prakash
2 Replies

3. Shell Programming and Scripting

Merging column files

Hi,Iam new to Unix.I have a file FileA which is a variable length file where each column is seperated by delimitter "|". FileA: SrNo Name Address 1-234|name1|Addr1 1-34|name2|Addr2 1-2345|name3|Addr3 FileB: SrNo Address 1-34<<06 SPACES>>Addr1<<8 spaces>> 1-234<<05... (1 Reply)
Discussion started by: swapna321
1 Replies

4. Shell Programming and Scripting

merging column from two files based on identifier

Hi, I have two files consisting of two columns. So I want to merge column 2 if column 1 is the same. So heres an example of what I mean. FILE1 driver 444 car 333 hat 222 FILE2 driver 333 car 666 hat 999 So I want to merge the column 2's together so... (4 Replies)
Discussion started by: phil_heath
4 Replies

5. Shell Programming and Scripting

Merging 2 files based on a common column

Hi All, I do have 2 files file 1 has 4 tab delimited columns 234 a c dfgyu 294 b g fih 302 c h jzh 328 z c san 597 f g son File 2 has 2 tab delimted columns 234 23 302 24 597 24 I want to merge file 2 with file 1 based on the data common in both files which is the first column so... (6 Replies)
Discussion started by: Lucky Ali
6 Replies

6. Shell Programming and Scripting

merging two files based on first column

I had two files file1 and file2. I want a o/p file(file3) like below using first column as ref. Pls give suggestion ass join is not working as the number of lines in each file is nealry 5 C? file1 --------------------- 404000324810001 Y 404000324810004 N 404000324810008 Y 404000324810009 N... (1 Reply)
Discussion started by: p_sai_ias
1 Replies

7. UNIX for Dummies Questions & Answers

Merging two text files by a column

I have two text files. One has two columns and looks like below: rs# otherallele_freq rs10399749 0 rs4030303 0 rs4030300 0 rs940550 1.000 rs13328714 0 rs11490937 0 rs6683466 0 rs12025928 1.000 rs6650104 0 rs11240781 0... (5 Replies)
Discussion started by: evelibertine
5 Replies

8. UNIX for Dummies Questions & Answers

Merging two text files by a column and filling in the missing values

Hi, I have to text files that I want to merge by the first column. The values in the first column pretty much match for the first part. However there are some values that are present in column 1 and not present in column 2 or vice versa. For such values I would like to substitute X for the... (9 Replies)
Discussion started by: evelibertine
9 Replies

9. Shell Programming and Scripting

Merging columns based on one or more column in two files

I have two files. FileA.txt 30910 rs7468327 36587 rs10814410 91857 rs9408752 105797 rs1133715 146659 rs2262038 152695 rs2810979 181843 rs3008128 182129 rs3008131 192118 rs3008170 FileB.txt 30910 1.9415219673 0 36431 1.3351312477 0.0107191428 36587 1.3169171182... (2 Replies)
Discussion started by: genehunter
2 Replies

10. Shell Programming and Scripting

Merging 2 text files when there is a common time stamp column in them

Dear Unix experts and users I have 2 kinds of files like below, of which I need to merge them in the order of time. File1: Date_Time Context D1 D2 04/19/2013_23:48:54.819 ABCD x x 04/19/2013_23:48:55.307 ABCD x x 04/19/2013_23:48:55.823 ABCD x ... (7 Replies)
Discussion started by: ks_reddy
7 Replies
TEXI2DVI(1)							   User Commands						       TEXI2DVI(1)

NAME
texi2dvi - convert Texinfo documents to DVI or PDF SYNOPSIS
texi2dvi [OPTION]... FILE... texi2pdf [OPTION]... FILE... pdftexi2dvi [OPTION]... FILE... DESCRIPTION
Run each Texinfo or (La)TeX FILE through TeX in turn until all cross-references are resolved, building all indices. The directory contain- ing each FILE is searched for included files. The suffix of FILE is used to determine its language ((La)TeX or Texinfo). To process (e)plain TeX files, set the environment variable LATEX=tex. In order to make texi2dvi a drop-in replacement of TeX/LaTeX in AUC-TeX, the FILE may also be composed of the following simple TeX com- mands. `input{FILE}' the actual file to compile ` onstopmode' same as --batch When invoked as `texi2pdf' or `pdftexi2dvi', or given the option --pdf or --dvipdf, generate PDF output. Otherwise, generate DVI. General options: -b, --batch no interaction -D, --debug turn on shell debugging (set -x) -h, --help display this help and exit successfully -o, --output=OFILE leave output in OFILE; only one input FILE is allowed -q, --quiet no output unless errors (implies --batch) -s, --silent same as --quiet -v, --version display version information and exit successfully -V, --verbose report on what is done Output format: --dvi output a DVI file [default] --dvipdf output a PDF file via DVI (using a dvi-to-pdf program) --html output an HTML file from LaTeX, using HeVeA --info output an Info file from LaTeX, using HeVeA -p, --pdf use pdftex or pdflatex for processing --ps output a PostScript file via DVI (using dvips) --text output a plain text file from LaTeX, using HeVeA TeX tuning: -@ use @input instead of input for preloaded Texinfo -e, -E, --expand force macro expansion using makeinfo -I DIR search DIR for Texinfo files -l, --language=LANG specify LANG for FILE, either latex or texinfo --no-line-error do not pass --file-line-error to TeX -r, --recode call recode before TeX to translate input --recode-from=ENC recode from ENC to the @documentencoding --shell-escape pass --shell-escape to TeX --src-specials pass --src-specials to TeX -t, --command=CMD insert CMD in copy of input file or --texinfo=CMD multiple values accumulate --translate-file=FILE use given charset translation file for TeX Build modes: --build=MODE specify the treatment of auxiliary files [local] --tidy same as --build=tidy -c, --clean same as --build=clean --build-dir=DIR specify where the tidy compilation is performed; implies --tidy; defaults to TEXI2DVI_BUILD_DIRECTORY [.] --mostly-clean remove the auxiliary files and directories but not the output --max-iterations=N don't process files more than N times The MODE specifies where the TeX compilation takes place, and, as a consequence, how auxiliary files are treated. The build mode can also be set using the environment variable TEXI2DVI_BUILD_MODE. Valid MODEs are: `local' compile in the current directory, leaving all the auxiliary files around. This is the traditional TeX use. `tidy' compile in a local *.t2d directory, where the auxiliary files are left. Output files are copied back to the original file. `clean' same as `tidy', but remove the auxiliary directory afterwards. Every compilation therefore requires the full cycle. Using the `tidy' mode brings several advantages: - the current directory is not cluttered with plethora of temporary files. - clutter can be even further reduced using --build-dir=dir: all the *.t2d directories are stored there. - clutter can be reduced to zero using, e.g., --build-dir=/tmp/$USER.t2d or --build-dir=$HOME/.t2d. - the output file is updated after every successful TeX run, for sake of concurrent visualization of the output. In a `local' build the viewer stops during the whole TeX run. - if the compilation fails, the previous state of the output file is preserved. - PDF and DVI compilation are kept in separate subdirectories preventing any possibility of auxiliary file incompatibility. On the other hand, because `tidy' compilation takes place in another directory, occasionally TeX won't be able to find some files (e.g., when using graphicspath): in that case, use -I to specify the additional directories to consider. The values of the BIBTEX, DVIPDF, DVIPS, HEVEA, LATEX, MAKEINDEX, MAKEINFO, PDFLATEX, PDFTEX, T4HT, TEX, TEX4HT, TEXINDEX, and THUMBPDF environment variables are used to run those commands, if they are set. Regarding --dvipdf, if DVIPDF is not set in the environment, the following programs are looked for (in this order): dvipdfmx dvipdfm dvipdf dvi2pdf dvitopdf. Any CMD strings are added after @setfilename for Texinfo input, or in the first line for LaTeX input. REPORTING BUGS
Report bugs to bug-texinfo@gnu.org, general questions and discussion to help-texinfo@gnu.org. GNU Texinfo home page: <http://www.gnu.org/software/texinfo/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for texi2dvi is maintained as a Texinfo manual. If the info and texi2dvi programs are properly installed at your site, the command info texi2dvi should give you access to the complete manual. texi2dvi 5234 March 2013 TEXI2DVI(1)
All times are GMT -4. The time now is 05:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy