Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How do I read/find/replace fields in a csv datafile? Post 302207514 by MrCarter on Friday 20th of June 2008 06:35:01 AM
Old 06-20-2008
..an error is being returned when I try to run this either by itself or in a script - am I not running it right?

$ cat SLsTester_DataFile.csv | awk BEGIN{FS=OFS=","}{for(i=1;i<=NF;i++){if($i=="0"){$i=""}}}1' file;

..the error given reads:

-bash: syntax error near unexpected token `('

your assistance is very much appreciated..

regards, Steven
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace one section in a datafile

Hi: First, this is not a homework problem. I just need enough of a hint to get this going... My datafile (dataf.in) is made up of 10 sections. Each section begins with & and with && So it looks like this:------------------------------------- &section1 ...etc... && &section2 ...etc...... (4 Replies)
Discussion started by: Paprika
4 Replies

2. Shell Programming and Scripting

Combine a datafile with Master datafile, emergent!

Hi guys, my supervisor has asked me to solve the problem in 7 days, I've taken 3 days to think about it but couldn't figure out any idea. Please give me some thoughts with the following problem, I have index.database that has only index date: 1994 1995 1996 1997 1998 1999 I have... (6 Replies)
Discussion started by: onthetopo
6 Replies

3. Shell Programming and Scripting

find & replace comma in a .csv file.

HI, Please find the text below. I receive a .csv file on server. I need the comma(,) in the second column to be replaced by a semi-colon( ; ). How to do it. Please help. Sample text: "1","lastname1,firstname1","xxxxxx","19/10/2009","23/10/2009","0","N","Leave"... (2 Replies)
Discussion started by: libin4u2000
2 Replies

4. Shell Programming and Scripting

How to read and parse the content of csv file containing # as delimeter into fields using Bash?

#!/bin/bash i=0 cat 1.csv | while read fileline do echo "$fileline" IFS="#" flds=( $fileline ) nrofflds=${#flds} echo "noof fields$nrofflds" fld=0 while do echo "noof counter$fld" echo "$nrofflds" #fld1="${flds}" trying to store the content of line to fields but i... (4 Replies)
Discussion started by: barani75
4 Replies

5. Shell Programming and Scripting

Converting .xls into .csv and find & Replace

Hi All, Please give me the solution to the following ASAP. 1) Converting the .xls into .csv Script i tried, mv hello.xls hello.csv The above given script converting the .xls file into .csv successfully. But after i run the below unix command I am no able to open the .csv file, its giving... (4 Replies)
Discussion started by: velava
4 Replies

6. Shell Programming and Scripting

Read Field from file1 and find and replace in file2

Hi All, I have file1 line below: $myName$|xxx Now I need to read the file1 and find for $myName$ in file2 and replace with xxx file1: $myName$|xxx file2: My name is $myName$ expected output in file2 after executing the script is below: my name is xxx Thanks, (8 Replies)
Discussion started by: gdevadas
8 Replies

7. Shell Programming and Scripting

Find and Replace in multiple fields using awk

Hi, Say I have a record "1|22| | |". In which the third and fourth fields are <space> alone. I have to replace the <Space> with <null>. Input: "1|22| | |" --> "1|22|<space> |<space> |" Expected output: "1|22|||" --> "1|22|<null> |<null>|" I tried: echo "1|22| | |" | awk -F... (4 Replies)
Discussion started by: machomaddy
4 Replies

8. Shell Programming and Scripting

Find and replace variables using a csv table

I have a flat file (template) where I want to replace variables based upon a value in another file (csv). The variables in the template are named %VAR_X_z% The values are in the csv file and X is field 0 of each line and y field 1 and up. Example of the csv: Badidas, 13.00, 12.00, 11.00,... (8 Replies)
Discussion started by: biscayne
8 Replies

9. Shell Programming and Scripting

Read in numbers from a datafile

Hi, I want to be able to read numbers from many files which have the same general form as follows: C3H8 4.032258004031807E-002 Phi = 1.000000E+00 Tau = 5.749E+00 sL0 = 3.805542E+01 dL0 = 1.514926E-02 Tb = 2.328291E+03 Tu = 3.450E+02 Alpha = ... (3 Replies)
Discussion started by: lost.identity
3 Replies

10. Shell Programming and Scripting

Find fields and replace using awk

Code: Using ksh Var1=`awk -F";" {print $1}' Input2.txt` cat Input1.txt | awk -F";" '{$3="Var1"}' > Output.txt (13 Replies)
Discussion started by: Roozo
13 Replies
Xmark(1)						      General Commands Manual							  Xmark(1)

NAME
Xmark - summarize x11perf results SYNTAX
Xmark datafile DESCRIPTION
Xmark is a shell script that reads the indicated datafile and compiles a benchmark which it writes to standard output. It writes three numbers: A weighted performance number for the x11perf results. A weighted performance number for a standard SparcStation 1, with SunOS 4.1.2, X11R5 Xsun, and a CG3 dumb Color Frame Buffer. The Xmark, which is the ratio of the two numbers above. The datafile must be an ordinary file, produced by x11perf in the following way: x11perf -display display -v1.3 -rop GXcopy GXxor -all > datafile It is possible to run the GXcopy and GXxor tests separately, as long as they are concatenated to the same output file: x11perf -display display -v1.3 -rop GXcopy -all > datafile x11perf -display display -v1.3 -rop GXxor -all >> datafile or x11perf -display display -v1.3 -rop GXxor -all > datafile x11perf -display display -v1.3 -rop GXcopy -all >> datafile FILES
temp.$$ Temporary file created in the current directory, deleted after use. DIAGNOSTICS
Usage: Xmark datafile Xmark was invoked without arguments or with more than one argument, or with options. Xmark takes no options. Error: data file does not exist or is not ordinary. Xmark cannot find the datafile named on its command line, or the datafile is a special file such as a directory. WARNING: datafile contains nnn, not 441 or 447 'trep' results; The file named on the command line does not seem to be a file generated by x11perf in the expected way. Diagnostic: ERROR: sum of weights =nnn, not equal to 4566.0; There is an internal error in Xmark. SEE ALSO
X(7), x11perf(1), x11perfcomp(1) X Version 11 x11perf 1.5.4 Xmark(1)
All times are GMT -4. The time now is 04:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy