Reversing large data set with awk?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reversing large data set with awk?
# 8  
Old 01-02-2018
Quote:
Originally Posted by Scrutinizer
In that case save this as "script.awk" or a name of your choice:
Code:
BEGIN {
  ORS=FS
}
{
  for(i=1; i<=6; i++)
    print $i
  for(i=NF-2; i>=7; i-=3)
    print $i, $(i+1), $(i+2)
  printf RS
}

And execute like this:
Code:
awk -f script.awk file > outfile

Smilie You are too cool
This behaves wonderfully. I cannot properly express my gratitude, me and the school district of Illinois thanks you from the bottom of our pea pickin hearts Smilie

I do have a follow-up question though! (if you don't mind)
The name of the 'infile' will not change, nor will its extension ever differ; it will always exist/download to the same directory every night. This awk script will live inside of the same directory as this particular file. Is it possible to have the awk script (before it does its BEGIN) look in the directory it lives in for a particular script?

Please remember, this is the school district of a state in the USA that will be implementing the functionality of this script, so command prompt is a very scary thing to them and I'm fairly certain that they won't even attempt to use it (even with very detailed instructions and minimal required effort). So just for the sake of ease (it's not necessary, they can suck it up if need be) but is it possible to simply double click the awk script file and have it run on a specific file inside the directory that it is executing in?

AGAIN!
Thank you so so much for your patience, experience, and time! You are a rockstar! Smilie
# 9  
Old 01-02-2018
You are welcome Smilie

I don't know much about Windows, but I think you can make it into a windows command that executes this command ( .CMD FILE ?). I seem to remember you can create a .cmd file, create a shortcut to it and then you can edit shortcut that in the graphics interface and even give it a different icon or something like that..

Or I think with right-click -> new -> shortcut you can create shortcut on the desktop and specify the command without using a .cmd file. And you can also specify the directory in which it should be executed..

Last edited by Scrutinizer; 01-02-2018 at 03:10 PM..
# 10  
Old 01-04-2018
Quote:
Originally Posted by Scrutinizer
You are welcome Smilie

I don't know much about Windows, but I think you can make it into a windows command that executes this command ( .CMD FILE ?). I seem to remember you can create a .cmd file, create a shortcut to it and then you can edit shortcut that in the graphics interface and even give it a different icon or something like that..

Or I think with right-click -> new -> shortcut you can create a shortcut on the desktop and specify the command without using a .cmd file. And you can also specify the directory in which it should be executed..
Smilie You are an angel Scrutinizer!
I found a link that seems to expand upon what you suggested and I believe it will do the trick! Bless your Heart!!!!
Hope you are having a lovely Wednesday! (I'll post a the link after I post this because currently I only have 4 posts and I need 5 to post a link)

---------- Post updated at 08:59 AM ---------- Previous update was at 08:59 AM ----------

windows - Run a Command Prompt command from Desktop Shortcut - Stack Overflow

---------- Post updated 01-04-18 at 08:04 AM ---------- Previous update was 01-03-18 at 08:59 AM ----------

In case anyone ever needs to run an AWK script from a lil bat file, here is what I did to get a bat script to call my awk script. I just wanted to minimize interaction with the command line because the folks who will be using this script are spooked by it! So now they have a nice double click exeCUTEable that will execute the awk script.

I made a script called 'invokeNodes.bat'; the contents of this file -->
Code:
awk -f nodes.awk ShapeData.txt > ShapeDataCorrected.txt

I saved this batch file into the same directory as the 'nodes.awk' script that is being called by the .bat. ShapeData (the file that is being edited by the awk script) is also contained inside the same directory as the .bat and the .awk.

Now all a user has to do (since the name of the file being edited will never change, just the data contained within) is double-click on the invokeNodes script and watch as it fixes the shapeData! Smilie

Many thanks to Scrutinizer for helping me so much through the process!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to make awk command faster for large amount of data?

I have nginx web server logs with all requests that were made and I'm filtering them by date and time. Each line has the following structure: 127.0.0.1 - xyz.com GET 123.ts HTTP/1.1 (200) 0.000 s 3182 CoreMedia/1.0.0.15F79 (iPhone; U; CPU OS 11_4 like Mac OS X; pt_br) These text files are... (21 Replies)
Discussion started by: brenoasrm
21 Replies

2. Programming

C++ help in large data set

Hi All, We are trying to replace a 3rdparty where we don't know how they handled the reader part here. The query below is getting 197 * 2038017 row in the table. In the below code we are trying to run the query and execute in the DB part and fetch and read the record. That is where it is... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

3. Shell Programming and Scripting

awk : Filter a set of data to parse header line and last field of multiple same match.

Hi Experts, I have a data with multiple entry , I want to filter PKG= & the last column "00060110" or "00088150" in the output file: ############################################################################################### PKG= P8SDB :: VGS = vgP8SOra vgP8SDB1 vgP8S001... (5 Replies)
Discussion started by: rveri
5 Replies

4. UNIX for Dummies Questions & Answers

Reversing line and word order using awk

Hello, I am new to awk and I was wandering if I could reverse line and word order from a text file using awk. I figured out how to do them both separately, but can't quite figure out how to mix them. Example: Input file: dog cat mouse 1 2 3 I am new to awk Output of the awk program:... (3 Replies)
Discussion started by: blink_w
3 Replies

5. Shell Programming and Scripting

Using AWK to separate data from a large XML file into multiple files

I have a 500 MB XML file from a FileMaker database export, it's formatted horribly (no line breaks at all). The node structure is basically <FMPXMLRESULT> <METADATA> <FIELD att="............." id="..."/> </METADATA> <RESULTSET FOUND="1763457"> <ROW att="....." etc="...."> ... (16 Replies)
Discussion started by: JRy
16 Replies

6. Shell Programming and Scripting

reversing and appending data in multiple files

Hello, I have a some files that look like this: 0 3 1 5 2 8 3 7 I want to reverse and append the data so it looks like this: 3 7 2 8 1 5 0 3 0 3 1 5 2 8 3 7 I first thought about using cat and tac cleverly with some redirection and pipe in a one-liner but I couldn't get it to... (1 Reply)
Discussion started by: bigfoot
1 Replies

7. Shell Programming and Scripting

Drop common lines at head/tail of a large set of files

Hi! I have a large set of pairs of text files (each pair in their own subdirectory) and each pair shares head/tail (a couple of first and last lines) but differs in the middle part. I need to delete the heads/tails and keep only the middle portions in which they differ. The lengths of heads/tails... (1 Reply)
Discussion started by: dobryden
1 Replies

8. Shell Programming and Scripting

awk and reversing

Hello I'm writing script in awk that reverse order the fields of every line in file. My script have problem with spaces - if there is more spaces between fields in line of file - my script erase them . I want my script work like command "tac" - how to change it ? #!/bin/sh file=$1... (1 Reply)
Discussion started by: scotty_123
1 Replies

9. HP-UX

large file options is set

Can someone tell me the right or exact syntax to check if the large file options is set on a filesystem Thanks! (2 Replies)
Discussion started by: catwomen
2 Replies
Login or Register to Ask a Question