Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. chino10

    Sum multiple columns output to single row to in separate file.

    I just wanted to tell you both thank you very much for your help and your patience.
  2. chino10

    Sum multiple columns output to single row to in separate file.

    Thank you PHV. I guess I wasn't too far off. Am I correct in assuming that what this states is if x[1] is not empty then print all 6 fields "else" don't print anything. The "else" is basically implied?
  3. chino10

    Sum multiple columns output to single row to in separate file.

    Thank you Annihilannic. I tried to create a check however, my skills are basically nill. I have only managed to create a blank line before the commas.
  4. chino10

    Sum multiple columns output to single row to in separate file.

    Yes, I'm back with another challenge. Recently this script ran against an empty file (I just now became aware of this possibility) and it output the following: ,,,,, Is there a way to make this script output an empty file if the file it is run against is empty of any data? Thank you for any...
  5. chino10

    Sum multiple columns output to single row to in separate file.

    This works fantastic. Annihilannic thank you very much!
  6. chino10

    Check number of lines in a file

    I have a file that will have zero or more lines of data. What I need to do first is check the file to see if it has zero or 1 line of data. If it does I need to copy it to a specific directory as is, otherwise I need to run a function (which I already have) against it before sending it to the...
  7. chino10

    Sum multiple columns output to single row to in separate file.

    PHV, I found a slight problem on our end when I use your script: BEGIN{FS=OFS=","} function myprint(){ if(NR>1)print x[1],x[2],x[3],x[4],x[5],x[6] split($0,x,",");b=$1 } b!=$1{myprint();next} {x[3]+=$3;x[5]+=$5} END{myprint()} Although created for mulitple lines of data we have the...
  8. chino10

    Sum multiple columns output to single row to in separate file.

    PHV you rock! This works beautifully. Thank you for your help and patience.
  9. chino10

    Sum multiple columns output to single row to in separate file.

    Thank you PHV this worked. However, I did not stop to consider the possibility that the input file may contain additional lines of information that are not related to each other but still aggregate the same: 0000229351,4,5.00,533017068270,31.96,UPAC 0000229351,4,3.00,533017068280,27.08,UPAC...
  10. chino10

    Sum multiple columns output to single row to in separate file.

    Thank you PHV. Sorry it took so long to respond. I forgot to mention I am using gawk in a windows command line environment and am receiving the following error: C:\Windows\system32>awk -F, "NR==1{split($0,x,",")}NR>1{x[3]+=$3;x[5]+=$5}END{OF S=",";print x[1],x[2],x[3],x[4],x[5],x[6]}"...
  11. chino10

    Sum multiple columns output to single row to in separate file.

    I am hoping someone can help me find a way to sum two columns but output the answer into a separate file using the first row of the original file as such: 0000229351,4,5.00,533017068270,31.96,UPAC 0000229351,4,3.00,533017068280,27.08,UPAC 0000229351,4,5.00,533017068291,31.96,UPAC...
  12. chino10

    Delete similar records under specific conditions using gawk

    Awesome! It looks like that was the problem. I originally put it in MS word and apparently the formatting threw it off. I did it in notepad and worked like a charm. Thank you very much! Annihilannic thank you very much! Tek-Tips rocks!
  13. chino10

    Delete similar records under specific conditions using gawk

    This is the contents of the file I created: { r[NR]=$0 if ($1!="") { ix=$1 } } $NF == "\"Y\"" { s[ix] } END { for (i=1;i<=NR;i++) { split(r[i],a,",") if (a[1]!="") { ix=a[1] } if (!(ix in s)) { print r[i] } } }...
  14. chino10

    Delete similar records under specific conditions using gawk

    Feherke thank you for responding so quickly. I set it up as you stated but I received the following error: gawk: -F gawk: ^ invalid char ‘-‘ in expression Also, does it matter what the extension is for the "separate" file (i.e., chino_10.awk)?
  15. chino10

    Delete similar records under specific conditions using gawk

    Thank you for responding Annihilannic. I attempted to make this work in a dos environment but continue to receive the following error: "The system cannot find the file specified". I am sure it's because I don't have the syntax correct yet but if, by chance, you have any additional tips I would...
  16. chino10

    Delete similar records under specific conditions using gawk

    I am completely new to shell scripting but have been assigned the task of creating several batch files to manipulate data in a windows environment. My final task requires me to find rows in a .csv document where the last column is “Y” then delete not only the duplicate(s) but the original as...

Part and Inventory Search

Back
Top