i have a large csv file with 150 columns, a sample of which is given below::
id,c1,c2,c3,c4,c5...
1,0,acc,123.4E+03,0,bdd,...
2,1.299E-05,bef,1.666E-08,23,ghh....
As u can see some fields are having values in scientific notations(which all columns are having values in scientific notations is not known given the fact that the csv file has over 5 Billion rows).
I need to convert the values in scientific notations to its corresponding decimal form. I came across the following solution: Convert scientific notation to decimal in multiple fields and obtained the following code:
#!/usr/bin/awk -f
BEGIN {
d = "[[:digit:]]"
OFS = FS = ","
}
{
delim = ""
for (i = 1; i <= NF; i++) {
if ($i ~ d "E+" d d d "$") {
printf "%s%.41f", delim, $i
}
else {
printf "%s%s", delim, $i
}
delim = OFS
}
printf "\n"
}
But the above script is not working for me. The above script returns my input file as it is(for E+ values and for E- values) without no conversion. I'm fairly new to shell scripting, Any ideas?
I'm executing the script in this form:
chmod u+x awkscript.awk
./awkscript.awk inputfile.csv