06-20-2008
How do I read/find/replace fields in a csv datafile?
hello.
I'm somewhat a novice here so please be patient. My stumbling block when loading csvs into ORACLE tables is this:
I need to read a csv datafile, check several fields in each line, and if any of stated fields contain A ZERO only [instead of YYYYMONDD date field expected] then replace it with a null/blank character.
I had a go at:
cat <datafile> | awk ‘$5 == “0” { “ “ } END { print }';
cat <datafile> | awk ‘$8 == “0” { “ “ } END { print }'; ..etc..
..alas it didn't work..
all advice/comments very much appreciated
Steven.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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:-------------------------------------
§ion1
...etc...
&&
§ion2
...etc...... (4 Replies)
Discussion started by: Paprika
4 Replies
2. Shell Programming and Scripting
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
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
#!/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
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
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
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
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
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
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