Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Adding new columns to txt files Post 302550346 by forevertl on Thursday 25th of August 2011 12:00:39 PM
Old 08-25-2011
Adding new columns to txt files

Dear all,
I have a question. I have a txt.file as below. i want to add 3 more columns: column3=conlum 2*column2; column4=(1-column2)*(1-column2); column5=1-column3-column4. Do you know how to do it? Thanks a lot!

file:
column1 column2
a 1
b 20
c 30
d 3
...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding columns to excel files using Perl

How do I add 4 columns to an excel file using Perl? The 4 headers for those columns will all have different names? Please help and I greatly appreciate... (1 Reply)
Discussion started by: dolo21taf
1 Replies

2. Shell Programming and Scripting

comparing files - adding/subtracting/formating columns

I have two files: file1.txt: FS Total Used Free Used% /u01 10000 8000 2000 80% /u02 10000 8000 2000 80% /u03 10000 8000 2000 80% /u04 10000 8000 2000 80% /u05 10000 8000 2000 80% /u06 10000 8000 2000 80% /u07 10000 8000 2000 80% /u10 10000 5000 5000 50% file2.txt:... (7 Replies)
Discussion started by: oabdalla
7 Replies

3. Shell Programming and Scripting

awk adding columns from different files

Hi, I have two files and I need to add column 3 of file1 to column 3 of file 2 > file3 I also need to repeat for column 4. Thanks (1 Reply)
Discussion started by: dsstamps
1 Replies

4. UNIX for Dummies Questions & Answers

Adding EMPTY columns to Tab-delimited txt file

Hi I have a txt file with 4 columns where I need to add 4 empty columns in the middle meaning that I need what is currently column 4 to be column 8 in a new file. The idea is that I have to use the file as input in a program that reads the data in column 1 and 8, so the content of the other... (8 Replies)
Discussion started by: Banni
8 Replies

5. Shell Programming and Scripting

Adding columns of two files

Hello everyone, I have two files containing 6 columns and thousands of rows. I want to add them (i.e. first column of first file + first column of second file and so on) and print the output in a third file. Can you please help me. Thanks a lot (7 Replies)
Discussion started by: chandra321
7 Replies

6. UNIX for Dummies Questions & Answers

Combined many txt files by columns

Hi, I want to combined 500 .txt files (each file only has one line) to a single txt file (A.txt). for example, A1.txt with 12 23 34 45 A2.txt with 56 67 78 89 ...etc, so I have A1.txt, A2.txt... , A499.txt, A500.txt (1 Reply)
Discussion started by: AMBER
1 Replies

7. Shell Programming and Scripting

merging files and adding special columns

Hi everyone, I got a problem with merging files and hoped one of you would have an idea how to approach this issue. I tried it with awk, but didn't get far. This is what I have: I got 40 files looking like the ones below. All have three columns but the number of rows differs (20000 to 50000).... (6 Replies)
Discussion started by: TuAd
6 Replies

8. Shell Programming and Scripting

Adding Multiple Files via Columns

I have a number of files with multiple rows that I need to add together. Let say I have 10 files: Each file has a great number of rows and columns. I need to add these files together the following way. In other words, If, for example, file A occupies Columns 1 to 19, I want to add file B... (7 Replies)
Discussion started by: Ernst
7 Replies

9. Shell Programming and Scripting

Adding info to end of line if two columns match from files with different separators

I have two files (csv and vcf) which look exactly like this S1.csv func,gene,start,info "exonic","AL","2309","het" "exonic","NEF","6912","hom"S1.vcf ##fileinfo #CHROM POS ID INFO chr1 4567 rs323211 1/1:84,104,99 chr4 2309 rs346742 1/1:27,213,90 chr6 5834 ... (5 Replies)
Discussion started by: Sarah_19
5 Replies

10. Shell Programming and Scripting

Adding columns from 2 files with variable number of columns

I have two files, file1 and file2 who have identical number of rows and columns. However, the script is supposed to be used for for different files and I cannot know the format in advance. Also, the number of columns changes within the file, some rows have more and some less columns (they are... (13 Replies)
Discussion started by: maya3
13 Replies
grass-dbf(1grass)						Grass User's Manual						 grass-dbf(1grass)

NAME
grass-dbf - DBF driver DBF driver DBF driver in GRASS Defining the DBF driver The DBF driver is the default driver, in theory no user interaction is required. However, if the settings should be set back from a differ- ent to the DBF driver, the following step is required: # keep single quotes: db.connect driver=dbf database='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/' db.connect -p The dbf/ subdirectory in the mapset must exist or must be created by the user. Creating a DBF table Usually DBF tables are created by GRASS when generating a vector map with attributes (and using DBF as default attribute driver). If a DBF table has to be created manually, db.execute can be used or a spreadsheet application. Also db.copy is sometimes useful as well as db.in.ogr to import external tables. Supported SQL commands by DBF driver ALTER TABLE table ADD [COLUMN] columndef ALTER TABLE table DROP COLUMN colname CREATE TABLE table ( columndefs ) DROP TABLE table SELECT columns FROM table SELECT columns FROM table WHERE condition SELECT columns FROM table ORDER BY column DELETE FROM table DELETE FROM table WHERE condition INSERT INTO table VALUES (value1[,value2,...]) INSERT INTO table ( column1[,column2,...] ) VALUES (value1[,value2,...]) UPDATE table SET assignment1[,assignment2,...] UPDATE table SET assignment1[,assignment2,...] WHERE condition Operators available in conditions "=" : equal "<" : smaller than "<=" : smaller/equal than ">" : larger than ">=" : larger/equal than "<>" : not equal "~" : Substring matching (non-standard SQL) "%" : Substring matching (limited functionality) Arithmetic expressions using constants and field values are allowed in condition clauses and in the RHS of assignments. Usual precedence rules and bracketing (using '(' and ')') are supported. Type conversion is performed if necessary (experimental). Conditions allow boolean expressions using the AND, OR and NOT operators, with the usual precedence rules. NULLs can be tested by 'colname IS NULL' in conditions. The negation is 'colname NOT NULL'. Sorting: Empty fields in a character column are sorted to the end. LIMITATIONS OF THE DBF DRIVER
The DBF driver supports only a few SQL statements since the DBF tables are intended for simple table storage. DBF column names are limited to 10 characters (as defined in the DBF specifications). For example, aggregate functions (sum, count, min, max,...) are not supported in SELECT clauses; mathematic functions (sin, cos, exp, log,...) are not supported in expressions; SQL query with IN are not supported. ERROR MESSAGES
An error message such as: DBMI-DBF driver error: SQL parser error: syntax error, unexpected NAME processing 'IN'.. indicates that an unsupported SQL statement (here, 'IN') was used. The only solution is to switch the DBMI backend to a real SQL engine (SQLite, PostgreSQL, MySQL etc.). See SQL support in GRASS GIS. An error message such as: DBMI-DBF driver error: SQL parser error: syntax error, unexpected DESC, expecting NAME processing 'DESC' indicates that a column name corresponds to a reserved SQL word (here: 'DESC'). A different column name should be used. If this happens during import with v.in.ogr, the cnames parameter can be used to assign different column names on the fly. SEE ALSO
db.connect, SQL support in GRASS GIS DBF Specifications (Shapelib) Last changed: $Date: 2011-02-07 18:59:50 +0100 (Mon, 07 Feb 2011) $ Help Index GRASS 6.4.2 grass-dbf(1grass)
All times are GMT -4. The time now is 06:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy