pydata

Keep Looking, Don't Settle

2019-05-18 Week 20 -- awk

awk -F, '{OFS="\t";print $3,$4}' mo_orders_weekly_2019-04-27.txt   ==>   awk '{print $4","$5}' mo_orders_weekly_2019-04-27.txt

cat mo_orders_weekly_2019-04-27.txt | cut -d ',' -f3    ==>    cat mo_orders_weekly_2019-04-27.txt | cut  -f3-4

awk -F, '{OFS=",";print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$20,$21}' infile.csv > outfile.csv

something else to consider - and this faster and more concise:

cut -d "," -f1-10,20-25,30-33 infile.csv > outfile.csv

Reference

  1. graph link
  2. How to concatenate multiple column values into a single column in Panda dataframe
  3. how do I insert a column at a specific column index in pandas?
  4. What is the 'cls' variable used for in Python classes?
  5. Bash - how to run a command after the previous finished?
  6. generate CSV file using AWK script
  7. Printing column separated by comma using Awk command line
  8. Check existence of input argument in a Bash shell script bash if [ $# -eq 0 ] then echo "No arguments supplied" fi The $# variable will tell you the number of input arguments the script was passed.

    Or you can check if an argument is an empty string or not like: bash if [ -z "$1" ] then echo "No argument supplied" fi The -z switch will test if the expansion of "$1" is a null string or not. If it is a null string then the body is executed.

  9. Crontab - Run in directory bash cd /path/to/directory && ./bin/myapp Concerning the use of && instead of ;: normally it doesn't make a difference, but if the cd command fails (e.g. because the directory doesn't exist) with && the application isn't executed, whereas with ; it's executed (but not in the intended directory).

  10. Running a cron job manually and immediately

  11. Python Execute Unix / Linux Command Examples
  12. Python: executing shell script with arguments(variable), but argument is not read in shell script python Process=Popen('./childdir/execute.sh %s %s' % (str(var1),str(var2),), shell=True)

  13. Popen error: [Errno 2] No such file or directory

  14. wait process until all subprocess finish? [duplicate] python exit_codes = [p.wait() for p in p1, p2]

  15. How to import the class within the same directory or sub directory?

  16. Extract specific columns from delimited file using Awk
  17. How to split a string in bash delimited by tab