|
Home > Archive > Unix Shell > January 2006 > AWK help
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| FYI,
Text file looks as below
inputfile.txt
------------------------------------------------------
Criteria:,Concept '07530'; Agreement Analyst 'Angela Harris'; Agreement
'2040'; Pay To '6377 001 48029'; Franchise Code '7899'; Owner Name
'Davis'; Settlement Due Date 'Greater Than'= '01/01/1999';
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,
Check #,Check Date,Payment Amount,Pay To Account ID,Franchise Code,Pay
To Name,Pay To Address,Pay To City,Pay To State,Pay To Zip,Owner
Name,Outlet ID,Outlet Name,Outlet Address,Outlet City,Outlet
State,Outlet Zip,Status,Effective Date,Store #,Multi-Concept
Code,Multi-Concept Type,Multi-Concept Description,2003 Advance
Volume,2003 National Beverage Adv - Rate,2003 Base Beverage Adv -
Rate,2003 Brand Enhancement Adv - Rate,2003 Advertising Fund Adv -
Rate,2003 Required Products Fund Adv - Rate,2003 Price Protection Adv -
Rate,2003 Advance Rate,2003 Advance Amount,2003 WCP Base Funding Adv -
Volume,2003 WCP Base Funding Adv - Rate,2003 WCP Base Funding Adv -
Amount,2003 TOTAL FOUNTAIN ADVANCE,Total Actual Volume,WCP Sampling
Volume,Net Actual Volume,2003 National Beverage Actual - Rate,2003 Base
Beverage Actual - Rate,2003 Brand Enhancement Actual - Rate,2003
Advertising Fund Actual - Rate,2003 Required Products Actual -
Rate,2003 Total Actual Rate,2003 Actual Amount - Sub Total,2003 Price
Protection P13'02 - P1'03 Actual - Volume,2003 Price Protection P13'02
- P1'03 Actual - Rate,2003 Price Protection P13'02 - P1'03 Actual -
Amount,2003 Price Protection P2'03 -P13'03 Actual - Volume,2003 Price
Protection P2'03 -P13'03 Actual - Rate,2003 Price Protection P2'03
-P13'03 Actual - Amount,2003 Price Protection Actual Amount,2003 WCP
Base Funding Actual - Volume,2003 WCP Base Funding Actual - Rate,2003
WCP Base Funding Actual - Amount,2003 TOTAL FOUNTAIN ACTUAL,2003 TOTAL
FOUNTAIN RECONCILIATION,Water Filter Deduction - Amount,WCP Deduction -
Amount,2004 Advance Volume,2004 National Beverage Adv - Rate,2004 Base
Beverage Adv - Rate,2004 Brand Enhancement Adv - Rate,2004 Advertising
Fund Adv - Rate,2004 Required Products Adv - Rate,2004 Price Protection
Adv - Rate,2004 Total Advance Rate,2004 Advance Amount Sub Total,2004
WCP Base Funding Adv - Volume,2004 WCP Base Funding Adv - Rate,2004 WCP
Base Funding Adv - Amount,2004 TOTAL FOUNTAIN ADVANCE,2004 TOTAL
FOUNTAIN PAYMENT,2003 Bottle & Can Adv - Volume,2003 Bottle & Can Adv -
Rate,2003 Bottle & Can Adv - Amount,2003 Bottle & Can Actual -
Volume,2003 Bottle & Can Actual - Rate,2003 Bottle & Can Actual -
Amount,2003 TOTAL B & C RECONCILIATION,2004 Bottle & Can Adv -
Volume,2004 Bottle & Can Adv - Rate,2004 Bottle & Can Adv -
Amount,TOTAL B&C PAYMENT,TOTAL PAYMENT,Fountain Actual Volume
Adjustment,Fountain Actual Volume Adjustment Reason,WCP Actual Volume
Adjustment,WCP Actual Volume Adjustment Reason,B&C Actual Volume
Adjustment,B&C Actual Volume Adjustment Reason,Fountain Advance Volume
Adjustsment,Fountain Advance Volume Adjustment Reason,WCP Advance
Volume Adjustment,WCP Advance Volume Adjustment Reason,B&C Advance
Volume Adjustment,B&C Advance Volume Adjustment Reason,Notes / Comments
GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
10359,TACO BELL #004142(004142),902 NORTH MAIN
STREET,LA FAYETTE,GA,30728,I,9/10/2003,4142,,,,1240,$0.80 ,$1.16 ,$0.30
,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$4,253.20 ",0,$0.61 ,$0.00 ,"$4,253.20
",175,,175,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$544.25 ,160,$0.21
,$33.60 ,15,$0.32 ,$4.80 ,$38.40 ,0,$0.61 ,$0.00 ,$582.65
,"($3,670.55)",$0.00 ,"($47,628.00)",0,$0.80 ,$1.16 ,$0.30 ,$0.20
,$0.65 ,$0.38 ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00
,"($51,298.55)",0,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00
,$0.00 ,"($51,298.55)",-985,Change of Ownership in P2-2003 so moved 985
gallons to 831581510373,,"Change of Ownership in P2-2003, no volume to
move to 831581510373",,,,Inactive Store,,Inactive Store,,,
GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
10360,TACO BELL #016098(016098),105 TRION
ROAD,SUMMERVILLE,GA,30747,I,9/10/2003,16098,,,,1950,$0.80 ,$1.16 ,$0.30
,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$6,688.50 ",0,$0.61 ,$0.00 ,"$6,688.50
",350,,350,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,"$1,088.50
",350,$0.21 ,$73.50 ,0,$0.32 ,$0.00 ,$73.50 ,0,$0.61 ,$0.00 ,"$1,162.00
","($5,526.50)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65
,$0.38 ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($5,526.50)",0,$0.00
,$0.00 ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
,"($5,526.50)",-1690,Change of Ownership in P2-2003 so moved 1690
gallons to 831581810383,-40,Change of Ownership in P2-2003 so moved 40
gallons to 831581810383,,,,Inactive Store,,Inactive Store,,,
GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
10361,TACO BELL #017019,190 PACE
DRIVE,TRENTON,GA,30752,I,9/10/2003,17019,,,,1640,$0.80 ,$1.16 ,$0.30
,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$5,625.20 ",0,$0.61 ,$0.00 ,"$5,625.20
",250,,250,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$777.50 ,210,$0.21
,$44.10 ,40,$0.32 ,$12.80 ,$56.90 ,0,$0.61 ,$0.00 ,$834.40
,"($4,790.80)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$0.38
,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($4,790.80)",0,$0.00 ,$0.00
,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
,"($4,790.80)",-930,Change of Ownership in P2-2003 so moved 930 gallons
to 831581510374,,"Change of Ownership in P10-2003, no volume to move to
831581510374",,,,Inactive Store,,Inactive Store,,,
GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
10362,TACO BELL #018678,7867 ADAIRSVILLE HWY
NW,ADAIRSVILLE,GA,30103,I,9/10/2003,18678,,,,2210,$0.80 ,$1.16 ,$0.30
,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$7,580.30 ",0,$0.61 ,$0.00 ,"$7,580.30
",330,,330,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,"$1,026.30
",295,$0.21 ,$61.95 ,35,$0.32 ,$11.20 ,$73.15 ,0,$0.61 ,$0.00
,"$1,099.45 ","($6,480.85)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20
,$0.65 ,$0.38 ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00
,"($6,480.85)",0,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00
,$0.00 ,"($6,480.85)",-1675,Change of Ownership in P2-2003 so moved
1675 gallons to 831581510375,,"Change of Ownership in P10-2003, no
volume to move to 831581510375",,,,Inactive Store,,Inactive Store,,,
GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
41310,TACO BELL #016818,7761 RHEA COUNTY
HIGHWAY,DAYTON,TN,37321,I,9/10/2003,16818,,,,1720,$0.80 ,$1.16 ,$0.30
,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$5,899.60 ",0,$0.61 ,$0.00 ,"$5,899.60
",285,,285,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$886.35 ,235,$0.21
,$49.35 ,50,$0.32 ,$16.00 ,$65.35 ,0,$0.61 ,$0.00 ,$951.70
,"($4,947.90)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$0.38
,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($4,947.90)",0,$0.00 ,$0.00
,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
,"($4,947.90)",-1390,Change of Ownership in P2-2003 so moved 1390
gallons to 831581541344,-35,Change of Ownership in P10-2003 so moved 35
gallons to 831581541344,,,,Inactive Store,,Inactive Store,,,
GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
41311,TACO BELL #017685,310 RANKIN AVENUE
SOUTH,DUNLAP,TN,37327,I,9/10/2003,17685,,,,1485,$0.80 ,$1.16 ,$0.30
,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$5,093.55 ",0,$0.61 ,$0.00 ,"$5,093.55
",150,,150,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$466.50 ,140,$0.21
,$29.40 ,10,$0.32 ,$3.20 ,$32.60 ,0,$0.61 ,$0.00 ,$499.10
,"($4,594.45)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$0.38
,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($4,594.45)",0,$0.00 ,$0.00
,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
,"($4,594.45)",-760,Change of Ownership in P2-2003 so moved 760 gallons
to 831581541345,-15,Change of Ownership in P10-2003 so moved 15 gallons
to 831581541345,,,,Inactive Store,,Inactive Store,,,
---------------------------------------------------------------------------------------------------------------------------------
-----
The req 1 is as below,
Initially did tail +3 to inputfile.txt
1.Should extract columns 3,12,2 and the last column from the input
file .
The column 3 heading to be replaced with another name (refer YUM08
..csv)
command tried : awk -f "," '{printf "%s20 %s20 %s 20
&s20\n",$3,$12,$2,$NF}' input file.txt
gave the error as :In put line number is 1 , source file is 1 and
cannot have more than 199 characters.
Req 2 is as below
1.Should extract 3 fields and the 4th field is settlement due date ,
which is part of criteria ie line 2 data).
2. Column D is 1st field, column L is the 2nd field and , 3rd filed
is 'settlement due date' which is part of criteria. ie line 2 data).
4th field is comments which is the last field but the position of the
column varies dynamically.
In short the fourth field should extract the last field of the report.
3.The ouput filename should have the column names appended to it.
This has to be done in a shell script.
The o/p file is as follows:
File Name
YUM_CHECK _BACKUP.csv
Sl.No.
File Structure
Data Type
Precision
Scale
1
Pay To Account ID
NUMBER
22
2
Outlet ID
NUMBER
22
3
Settlement Due Date
DATE
4
Comments
TEXT
2000
My logic:
1.covert .csv to .txt for manipulation cp yum07.csv yum07.txt
2.split the file vertically into two files
file1.txt line2 of the source file
file2.txt from 5th line onwards( ( probably using head/tail command)
3. To get settlement due date
get the length of line 2 and using substr() extract it and store
itn
var_settlement_due_date
4. extract d , l columns ( probably using cut command)
5 extract the last column (not sure of the command)
6.make a temp file for the column names with comma as delimiter(
proably by creating a new file for the required headings or by
extracting the hedings for the specific fields)
7. Combine the o/p of 3,4 and 5
8.Form the file by combing the tmp file and field s
9. convert the txtfile to csv
This has to be done in shell script.
As I am not familiar with awk programming.Can you please guide .
Thanks
Dattu
| |
| Ed Morton 2006-01-20, 6:03 pm |
| Dattu wrote:
> FYI,
>
> Text file looks as below
>
> inputfile.txt
>
> ------------------------------------------------------
> Criteria:,Concept '07530'; Agreement Analyst 'Angela Harris'; Agreement
> '2040'; Pay To '6377 001 48029'; Franchise Code '7899'; Owner Name
> 'Davis'; Settlement Due Date 'Greater Than'= '01/01/1999';
> ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,
>
> Check #,Check Date,Payment Amount,Pay To Account ID,Franchise Code,Pay
> To Name,Pay To Address,Pay To City,Pay To State,Pay To Zip,Owner
> Name,Outlet ID,Outlet Name,Outlet Address,Outlet City,Outlet
> State,Outlet Zip,Status,Effective Date,Store #,Multi-Concept
> Code,Multi-Concept Type,Multi-Concept Description,2003 Advance
> Volume,2003 National Beverage Adv - Rate,2003 Base Beverage Adv -
> Rate,2003 Brand Enhancement Adv - Rate,2003 Advertising Fund Adv -
> Rate,2003 Required Products Fund Adv - Rate,2003 Price Protection Adv -
> Rate,2003 Advance Rate,2003 Advance Amount,2003 WCP Base Funding Adv -
> Volume,2003 WCP Base Funding Adv - Rate,2003 WCP Base Funding Adv -
> Amount,2003 TOTAL FOUNTAIN ADVANCE,Total Actual Volume,WCP Sampling
> Volume,Net Actual Volume,2003 National Beverage Actual - Rate,2003 Base
> Beverage Actual - Rate,2003 Brand Enhancement Actual - Rate,2003
> Advertising Fund Actual - Rate,2003 Required Products Actual -
> Rate,2003 Total Actual Rate,2003 Actual Amount - Sub Total,2003 Price
> Protection P13'02 - P1'03 Actual - Volume,2003 Price Protection P13'02
> - P1'03 Actual - Rate,2003 Price Protection P13'02 - P1'03 Actual -
> Amount,2003 Price Protection P2'03 -P13'03 Actual - Volume,2003 Price
> Protection P2'03 -P13'03 Actual - Rate,2003 Price Protection P2'03
> -P13'03 Actual - Amount,2003 Price Protection Actual Amount,2003 WCP
> Base Funding Actual - Volume,2003 WCP Base Funding Actual - Rate,2003
> WCP Base Funding Actual - Amount,2003 TOTAL FOUNTAIN ACTUAL,2003 TOTAL
> FOUNTAIN RECONCILIATION,Water Filter Deduction - Amount,WCP Deduction -
> Amount,2004 Advance Volume,2004 National Beverage Adv - Rate,2004 Base
> Beverage Adv - Rate,2004 Brand Enhancement Adv - Rate,2004 Advertising
> Fund Adv - Rate,2004 Required Products Adv - Rate,2004 Price Protection
> Adv - Rate,2004 Total Advance Rate,2004 Advance Amount Sub Total,2004
> WCP Base Funding Adv - Volume,2004 WCP Base Funding Adv - Rate,2004 WCP
> Base Funding Adv - Amount,2004 TOTAL FOUNTAIN ADVANCE,2004 TOTAL
> FOUNTAIN PAYMENT,2003 Bottle & Can Adv - Volume,2003 Bottle & Can Adv -
> Rate,2003 Bottle & Can Adv - Amount,2003 Bottle & Can Actual -
> Volume,2003 Bottle & Can Actual - Rate,2003 Bottle & Can Actual -
> Amount,2003 TOTAL B & C RECONCILIATION,2004 Bottle & Can Adv -
> Volume,2004 Bottle & Can Adv - Rate,2004 Bottle & Can Adv -
> Amount,TOTAL B&C PAYMENT,TOTAL PAYMENT,Fountain Actual Volume
> Adjustment,Fountain Actual Volume Adjustment Reason,WCP Actual Volume
> Adjustment,WCP Actual Volume Adjustment Reason,B&C Actual Volume
> Adjustment,B&C Actual Volume Adjustment Reason,Fountain Advance Volume
> Adjustsment,Fountain Advance Volume Adjustment Reason,WCP Advance
> Volume Adjustment,WCP Advance Volume Adjustment Reason,B&C Advance
> Volume Adjustment,B&C Advance Volume Adjustment Reason,Notes / Comments
> GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
> INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
> 10359,TACO BELL #004142(004142),902 NORTH MAIN
> STREET,LA FAYETTE,GA,30728,I,9/10/2003,4142,,,,1240,$0.80 ,$1.16 ,$0.30
> ,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$4,253.20 ",0,$0.61 ,$0.00 ,"$4,253.20
> ",175,,175,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$544.25 ,160,$0.21
> ,$33.60 ,15,$0.32 ,$4.80 ,$38.40 ,0,$0.61 ,$0.00 ,$582.65
> ,"($3,670.55)",$0.00 ,"($47,628.00)",0,$0.80 ,$1.16 ,$0.30 ,$0.20
> ,$0.65 ,$0.38 ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00
> ,"($51,298.55)",0,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00
> ,$0.00 ,"($51,298.55)",-985,Change of Ownership in P2-2003 so moved 985
> gallons to 831581510373,,"Change of Ownership in P2-2003, no volume to
> move to 831581510373",,,,Inactive Store,,Inactive Store,,,
> GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
> INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
> 10360,TACO BELL #016098(016098),105 TRION
> ROAD,SUMMERVILLE,GA,30747,I,9/10/2003,16098,,,,1950,$0.80 ,$1.16 ,$0.30
> ,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$6,688.50 ",0,$0.61 ,$0.00 ,"$6,688.50
> ",350,,350,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,"$1,088.50
> ",350,$0.21 ,$73.50 ,0,$0.32 ,$0.00 ,$73.50 ,0,$0.61 ,$0.00 ,"$1,162.00
> ","($5,526.50)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65
> ,$0.38 ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($5,526.50)",0,$0.00
> ,$0.00 ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
> ,"($5,526.50)",-1690,Change of Ownership in P2-2003 so moved 1690
> gallons to 831581810383,-40,Change of Ownership in P2-2003 so moved 40
> gallons to 831581810383,,,,Inactive Store,,Inactive Store,,,
> GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
> INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
> 10361,TACO BELL #017019,190 PACE
> DRIVE,TRENTON,GA,30752,I,9/10/2003,17019,,,,1640,$0.80 ,$1.16 ,$0.30
> ,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$5,625.20 ",0,$0.61 ,$0.00 ,"$5,625.20
> ",250,,250,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$777.50 ,210,$0.21
> ,$44.10 ,40,$0.32 ,$12.80 ,$56.90 ,0,$0.61 ,$0.00 ,$834.40
> ,"($4,790.80)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$0.38
> ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($4,790.80)",0,$0.00 ,$0.00
> ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
> ,"($4,790.80)",-930,Change of Ownership in P2-2003 so moved 930 gallons
> to 831581510374,,"Change of Ownership in P10-2003, no volume to move to
> 831581510374",,,,Inactive Store,,Inactive Store,,,
> GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
> INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
> 10362,TACO BELL #018678,7867 ADAIRSVILLE HWY
> NW,ADAIRSVILLE,GA,30103,I,9/10/2003,18678,,,,2210,$0.80 ,$1.16 ,$0.30
> ,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$7,580.30 ",0,$0.61 ,$0.00 ,"$7,580.30
> ",330,,330,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,"$1,026.30
> ",295,$0.21 ,$61.95 ,35,$0.32 ,$11.20 ,$73.15 ,0,$0.61 ,$0.00
> ,"$1,099.45 ","($6,480.85)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20
> ,$0.65 ,$0.38 ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00
> ,"($6,480.85)",0,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00
> ,$0.00 ,"($6,480.85)",-1675,Change of Ownership in P2-2003 so moved
> 1675 gallons to 831581510375,,"Change of Ownership in P10-2003, no
> volume to move to 831581510375",,,,Inactive Store,,Inactive Store,,,
> GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
> INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
> 41310,TACO BELL #016818,7761 RHEA COUNTY
> HIGHWAY,DAYTON,TN,37321,I,9/10/2003,16818,,,,1720,$0.80 ,$1.16 ,$0.30
> ,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$5,899.60 ",0,$0.61 ,$0.00 ,"$5,899.60
> ",285,,285,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$886.35 ,235,$0.21
> ,$49.35 ,50,$0.32 ,$16.00 ,$65.35 ,0,$0.61 ,$0.00 ,$951.70
> ,"($4,947.90)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$0.38
> ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($4,947.90)",0,$0.00 ,$0.00
> ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
> ,"($4,947.90)",-1390,Change of Ownership in P2-2003 so moved 1390
> gallons to 831581541344,-35,Change of Ownership in P10-2003 so moved 35
> gallons to 831581541344,,,,Inactive Store,,Inactive Store,,,
> GL10002048,2/1/2004,"($77,639.05)",8315FR908,,"THE PRICE MGMT CO.,
> INC.","100 PEACHTREE STREET, SUITE 1475",ATLANTA,GA,30303,Cox,8315 908
> 41311,TACO BELL #017685,310 RANKIN AVENUE
> SOUTH,DUNLAP,TN,37327,I,9/10/2003,17685,,,,1485,$0.80 ,$1.16 ,$0.30
> ,$0.20 ,$0.65 ,$0.32 ,$3.43 ,"$5,093.55 ",0,$0.61 ,$0.00 ,"$5,093.55
> ",150,,150,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$3.11 ,$466.50 ,140,$0.21
> ,$29.40 ,10,$0.32 ,$3.20 ,$32.60 ,0,$0.61 ,$0.00 ,$499.10
> ,"($4,594.45)",$0.00 ,$0.00 ,0,$0.80 ,$1.16 ,$0.30 ,$0.20 ,$0.65 ,$0.38
> ,$3.49 ,$0.00 ,0,$0.61 ,$0.00 ,$0.00 ,"($4,594.45)",0,$0.00 ,$0.00
> ,0,$0.00 ,$0.00 ,$0.00 ,0,$0.00 ,$0.00 ,$0.00
> ,"($4,594.45)",-760,Change of Ownership in P2-2003 so moved 760 gallons
> to 831581541345,-15,Change of Ownership in P10-2003 so moved 15 gallons
> to 831581541345,,,,Inactive Store,,Inactive Store,,,
> ---------------------------------------------------------------------------------------------------------------------------------
>
>
>
>
>
>
> -----
> The req 1 is as below,
>
> Initially did tail +3 to inputfile.txt
>
> 1.Should extract columns 3,12,2 and the last column from the input
> file .
>
> The column 3 heading to be replaced with another name (refer YUM08
> .csv)
>
> command tried : awk -f "," '{printf "%s20 %s20 %s 20
> &s20\n",$3,$12,$2,$NF}' input file.txt
ITYM:
awk -F "," '{printf "%20s %20s %20s %20s\n",$3,$12,$2,$NF}' inputfile.txt
> gave the error as :In put line number is 1 , source file is 1 and
> cannot have more than 199 characters.
You seem to have a problem with white-space in your posting. There are
spaces where there presumably shouldn't be (e.g. "input file.txt") and
no specaes where there presumably should be (e.g. newlines between
records of your input file.
Your input file also appears to have 2 very different formats of record
in it, 1 format for the first record (before the ",,,,,,,," line and
another after) which may or may not be in your real data.
I suggest you:
a) check which version of awk you're using. I suspect you're using old,
broken awk so instead use GNU awk (gawk - preferred), nawk, or
/usr/xpg4/bin/awk (on Solaris).
b) try the command again, clean up the formatting mistakes and post
again with the actual error message if any.
c) rather than posting a huge input file and list of requirements, you
might want to break it down into small problems with a small
representative (rather than real but huge) input and expected output so
there's less chance of people just skipping over your post.
Ed.
| |
| Bill Marcum 2006-01-20, 6:03 pm |
| On 19 Jan 2006 21:09:28 -0800, Dattu
<datteswararao@gmail.com> wrote:
>
> 1.Should extract columns 3,12,2 and the last column from the input
> file .
>
> The column 3 heading to be replaced with another name (refer YUM08
> .csv)
>
> command tried : awk -f "," '{printf "%s20 %s20 %s 20
> &s20\n",$3,$12,$2,$NF}' input file.txt
>
> gave the error as :In put line number is 1 , source file is 1 and
> cannot have more than 199 characters.
>
Are you sure it wasn't "cannot have more than 199 fields"? If you are
on Solaris, use nawk or /usr/xpg4/bin/awk.
>
> Req 2 is as below
>
> 1.Should extract 3 fields and the 4th field is settlement due date ,
> which is part of criteria ie line 2 data).
>
> 2. Column D is 1st field, column L is the 2nd field and , 3rd filed
> is 'settlement due date' which is part of criteria. ie line 2 data).
> 4th field is comments which is the last field but the position of the
> column varies dynamically.
> In short the fourth field should extract the last field of the report.
>
$NF is the last field.
--
Man who sleep in beer keg wake up sticky.
|
|
|
|
|