How to create a .csv file from 2 different .txt files?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to create a .csv file from 2 different .txt files?
# 1  
Old 05-21-2013
How to create a .csv file from 2 different .txt files?

Hi,

I need to create a .csv file from information that i have in two different tab delimited .txt file. I just want to select some of the columns of each .txt file and paste them into a .cvs file.

My files look like:

File 1

Code:
transcript_id       Seq. Description        Seq. Length     #Hits   min. eValue mean Similarity #GOs    GOs     Enzyme Codes    InterProScan
comp1000201_c0_seq1     ---NA---        337     0                       0       -               
comp1000297_c0_seq1     ---NA---        612     0                       0       -               
comp100036_c0_seq1      ---NA---        333     0                       0       -               
comp10003_c1_seq1       ---NA---        328     0                       0       -               
comp100041_c0_seq1      ---NA---        338     0                       0       -               
comp100041_c0_seq2      ---NA---        302     0                       0       -               
comp100041_c0_seq3      ---NA---        339     0                       0       -               
comp100051_c0_seq1      pogo transposable element with krab domain-like 323     5       8.05925533998611E-10    55.8%   0       -               
comp1000890_c0_seq1     ---NA---        460     0                       0       -               
comp1000928_c0_seq1     40s ribosomal protein s7        317     5       1.02118911037712E-20    66.6%   4       F:GO:0003735; P:GO:0006412; C:GO:0005840; C:GO:0005622

File 2

Code:
transcript_id   gene_id length  effective_length        expected_count  TPM     FPKM    IsoPct
comp1000201_c0_seq1     comp1000201_c0  337     183.51  0.00    0.00    0.00    0.00
comp1000297_c0_seq1     comp1000297_c0  612     458.50  0.00    0.00    0.00    0.00
comp100036_c0_seq1      comp100036_c0   333     179.51  1.00    6.72    6.17    100.00
comp10003_c1_seq1       comp10003_c1    328     174.51  0.00    0.00    0.00    0.00
comp100041_c0_seq1      comp100041_c0   338     184.51  0.00    0.00    0.00    0.00
comp100041_c0_seq2      comp100041_c0   302     148.52  0.00    0.00    0.00    0.00
comp100041_c0_seq3      comp100041_c0   339     185.51  0.00    0.00    0.00    0.00
comp100051_c0_seq1      comp100051_c0   323     169.51  0.00    0.00    0.00    0.00
comp1000890_c0_seq1     comp1000890_c0  460     306.51  2.00    7.87    7.23    100.00

What i want in the .csv file is the transcript_id and Seq. Description from File 1 and expected_count from File 2

Any suggestions?
Thanks.
# 2  
Old 05-22-2013
try.. just want to know is there any specific length for Seq Description?
Code:
  
awk 'NR==FNR{A[$1]=$4;next}
{if(A[$1]){print $1","$2","A[$1]}}' file2 file1

# 3  
Old 05-22-2013
Code:
 $ join --header file1 file2 | cut -d" " -f1,2,11
transcript_id Seq. #GOs
comp1000201_c0_seq1 ---NA--- 0.00
comp1000297_c0_seq1 ---NA--- 0.00
comp100036_c0_seq1 ---NA--- 1.00
comp10003_c1_seq1 ---NA--- 0.00
comp100041_c0_seq1 ---NA--- 0.00
comp100041_c0_seq2 ---NA--- 0.00
comp100041_c0_seq3 ---NA--- 0.00
comp100051_c0_seq1 pogo 55.8%
comp1000890_c0_seq1 ---NA--- 2.00

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Matching two fields in two csv files, create new file and append match

I am trying to parse two csv files and make a match in one column then print the entire file to a new file and append an additional column that gives description from the match to the new file. If a match is not made, I would like to add "NA" to the end of the file Command that Ive been using... (6 Replies)
Discussion started by: dis0wned
6 Replies

2. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

3. Shell Programming and Scripting

Comparing Select Columns from two CSV files in UNIX and create a third file based on comparision

Hi , I want to compare first 3 columns of File A and File B and create a new file File C which will have all rows from File B and will include rows that are present in File A and not in File B based on First 3 column comparison. Thanks in advance for your help. File A A,B,C,45,46... (2 Replies)
Discussion started by: ady_koolz
2 Replies

4. Shell Programming and Scripting

Merge CSV files and create a column with the filename from the original file

Hello everyone!! I am not completely new to shell script but I havent been able to find the answer to my problem and I'm sure there are some smart brains here up for the challenge :D. I have several CSV files that I need to combine into one, but I also need to know where each row came from.... (7 Replies)
Discussion started by: fransanchezoria
7 Replies

5. Shell Programming and Scripting

Parsing txt, xml files and preparing csv file

Hi, I need to parse text, xml files to get the statistic numbers and prepare summary csv file. What is the best way to parse these file and prepare csv file. Any idea you have , please? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

6. Shell Programming and Scripting

How to create a CSV File by reading fields from separate files

SHELL SCRIPT Hi, I have 3 separate files within a folder. Every File contains data in a single column like File1 contains data mayank sushant dheeraj File2 contains DSA_AT MG_AT FLAT_09 File3 contains data 123123 232323 (2 Replies)
Discussion started by: mayanksargoch
2 Replies

7. Shell Programming and Scripting

Merging files to create CSV file

Hi, I have different files of the same type, as: Time: 100 snr: 88 perf: 10 other: 222 Each of these files are created periodically. What I need to do is to merge all of them into one but having the following form: (2 Replies)
Discussion started by: Ravendark
2 Replies

8. Shell Programming and Scripting

Compare two csv files by two colums and create third file combining data from them.

I've got two large csv text table files with different number of columns each. I have to compare them based on first two columns and create resulting file that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Discussion started by: agb2008
5 Replies

9. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

10. UNIX for Dummies Questions & Answers

text drivers for .txt and .csv files ??

As a newcomer to UNIX I need to know if there are .txt and .csx ODBC drivers available. I want to import some data and the UNIX tech which I am in contact with does not know much about UNIX! He asked me to find out if these drivers existed or use a 'LOAD DATA INFILE' command, which is not too... (4 Replies)
Discussion started by: noodles
4 Replies
Login or Register to Ask a Question